home *** CD-ROM | disk | FTP | other *** search
/ Amiga CD-Sensation: Golden Games / Amiga CD-Sensation - Ausgabe 2 - Golden Games (1996)(GTI - Schatztruhe)(DE)[!].iso / Brain Activity / UChess / Source / main.c < prev    next >
C/C++ Source or Header  |  1994-06-28  |  170KB  |  6,331 lines

  1. // need to load the strings "new" "get" and "save"
  2. // for load/save/new games when in menu, then set
  3. // done to 1!!!
  4.  
  5. // NOTE THAT THE INPUT THREAD HAS TO BE THE ONE TO
  6. // GETGAME AND SAVE GAME THOUGH!! so it must all change
  7.  
  8. /*#define EIGHT_BIT_SCREEN 1 */
  9.  
  10. /* main.c - C source for GNU CHESS
  11.  *
  12.  * Copyright (c) 1988,1989,1990 John Stanback
  13.  * Copyright (c) 1992 Free Software Foundation
  14.  *
  15.  * This file is part of GNU CHESS.
  16.  *
  17.  * GNU Chess is free software; you can redistribute it and/or modify
  18.  * it under the terms of the GNU General Public License as published by
  19.  * the Free Software Foundation; either version 2, or (at your option)
  20.  * any later version.
  21.  *
  22.  * GNU Chess is distributed in the hope that it will be useful,
  23.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  25.  * GNU General Public License for more details.
  26.  *
  27.  * You should have received a copy of the GNU General Public License
  28.  * along with GNU Chess; see the file COPYING.  If not, write to
  29.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  30.  */
  31.  
  32. int __aligned CheckIllegal = 0;
  33. extern int IllegalMove;
  34. #include "version.h"
  35. #include "gnuchess.h"
  36. #include <signal.h>
  37. #include <ctype.h>
  38.  
  39. #ifdef AMIGA
  40. #define EXCLUDE_PATT 0xffffff00L
  41. #define __USE_SYSBASE
  42. #include <exec/types.h>
  43. #include <exec/exec.h>
  44. #include <exec/semaphores.h>
  45. #include <proto/exec.h>
  46. #include <proto/dos.h>
  47. #include <dos/dostags.h>
  48. #include <proto/graphics.h>
  49. #include <graphics/gfxbase.h>
  50. #include <proto/intuition.h>
  51. #include <utility/tagitem.h>
  52. #include <graphics/modeid.h>
  53. #include <lhlib.h>
  54. #include <libraries/asl.h>
  55. #include <proto/icon.h>
  56. #include <proto/asl.h>
  57. #include <workbench/startup.h>
  58. #include <workbench/workbench.h>
  59.  
  60.  
  61. #define mySetABPenDrMd(a,b,c,d) if (gfxversion > 38) {SetABPenDrMd(a,b,c,d);} else {SetAPen(a,b);SetDrMd(a,d);}
  62.  
  63. extern int backsrchaborted;
  64. extern int __aligned bookflag;
  65. struct TmpRas __aligned temp_rast;
  66. unsigned char *tempras_bitplane=(unsigned char *)0L;
  67.  
  68. struct __iobuf __iob[1];
  69.  
  70. struct SignalSemaphore __aligned mySemaphore; // should be all zeroed
  71.  
  72.  
  73.  
  74. #define LN2 693147 /* .693147 */
  75. #define LOGE_34 3526361 /* log2(34) = ln(34)/ln(2) = 5.087463 */
  76. #define LOGE_16 2772589 /* ln(16) = */
  77.  
  78. void SetTimeControl2 (int);
  79. void calc_pgm_rating(void);
  80. void DoEasy(void);
  81. void DoIntermediate(void);
  82. void DoAdvanced(void);
  83. int GetScreenMode(void);
  84.  
  85.  
  86. /* this table index ln(2)*1e6 - ln(1202)*1e6 by 6's */
  87. /* so take (#secs - 2)/6 for index into this table */
  88.  
  89.  
  90. char __aligned __far UCProcName[16]="UCTurbo Engine";
  91. char __aligned __far InputPortName[16]="UC Port";
  92. struct TagItem __aligned __far ProcTagList[8] = {
  93. {NP_Entry,(ULONG)InputThread},
  94. {NP_StackSize,4096L},
  95. {NP_Name,(ULONG)UCProcName},
  96. {0,0}
  97. };
  98.  
  99. extern INTSIZE __aligned amigaboard[64],amigacolor[64];
  100. extern int __aligned RealThink;
  101. int __aligned OpEntryRecvd=0;
  102. struct MsgPort __aligned *InputReply=(struct MsgPort *)0L;
  103. struct MsgPort *InThreadPort;
  104. int __aligned InputThreadState=0;
  105. struct myMsgStruct __aligned Global_Message;
  106. char __aligned OpEntryStr[64];
  107.  
  108. long __aligned OrigResponse;
  109. int __aligned __far log_e[]={
  110. 693147, 2079442, 2639057, 2995732, 3258097, 3465736, 3637586, 3784190, 
  111. 3912023, 4025352, 4127134, 4219508, 4304065, 4382027, 4454347, 4521789, 
  112. 4584967, 4644391, 4700480, 4753590, 4804021, 4852030, 4897840, 4941642, 
  113. 4983607, 5023881, 5062595, 5099866, 5135798, 5170484, 5204007, 5236442, 
  114. 5267858, 5298317, 5327876, 5356586, 5384495, 5411646, 5438079, 5463832, 
  115. 5488938, 5513429, 5537334, 5560682, 5583496, 5605802, 5627621, 5648974, 
  116. 5669881, 5690359, 5710427, 5730100, 5749393, 5768321, 5786897, 5805135, 
  117. 5823046, 5840642, 5857933, 5874931, 5891644, 5908083, 5924256, 5940171, 
  118. 5955837, 5971262, 5986452, 6001415, 6016157, 6030685, 6045005, 6059123, 
  119. 6073045, 6086775, 6100319, 6113682, 6126869, 6139885, 6152733, 6165418, 
  120. 6177944, 6190315, 6202536, 6214608, 6226537, 6238325, 6249975, 6261492, 
  121. 6272877, 6284134, 6295266, 6306275, 6317165, 6327937, 6338594, 6349139, 
  122. 6359574, 6369901, 6380123, 6390241, 6400257, 6410175, 6419995, 6429719, 
  123. 6439350, 6448889, 6458338, 6467699, 6476972, 6486161, 6495266, 6504288, 
  124. 6513230, 6522093, 6530878, 6539586, 6548219, 6556778, 6565265, 6573680, 
  125. 6582025, 6590301, 6598509, 6606650, 6614726, 6622736, 6630683, 6638568, 
  126. 6646391, 6654153, 6661855, 6669498, 6677083, 6684612, 6692084, 6699500, 
  127. 6706862, 6714171, 6721426, 6728629, 6735780, 6742881, 6749931, 6756932, 
  128. 6763885, 6770789, 6777647, 6784457, 6791221, 6797940, 6804615, 6811244, 
  129. 6817831, 6824374, 6830874, 6837333, 6843750, 6850126, 6856462, 6862758, 
  130. 6869014, 6875232, 6881411, 6887553, 6893656, 6899723, 6905753, 6911747, 
  131. 6917706, 6923629, 6929517, 6935370, 6941190, 6946976, 6952729, 6958448, 
  132. 6964136, 6969791, 6975414, 6981006, 6986566, 6992096, 6997596, 7003065, 
  133. 7008505, 7013915, 7019297, 7024649, 7029973, 7035269, 7040536, 7045777, 
  134. 7050989, 7056175, 7061334, 7066467, 7071573, 7076654, 7081709, 7086738, 
  135. 7091742};
  136.  
  137.  
  138. /* Structure for transparent images */
  139.  
  140. #define PTRHEIGHT 55
  141.  
  142. #define BLANKDATA 0xffff
  143.  
  144. extern int SecsPerMove;
  145. int __aligned lastpiece=BLANKDATA;
  146.  
  147. void Undo(void);
  148.  
  149. char __aligned __far vstring[64]={AVSTR};
  150.  
  151. long __far __aligned piecechar[12]={'p','n','b','r','q','k',
  152.                           'P','N','B','R','Q','K'};
  153. char __far __aligned oldboard[8][8];
  154.  
  155. int __far __aligned BACKPEN=1;
  156.  
  157. int __aligned BLACK=1;
  158.  
  159. //int __aligned Picasso=0L;
  160. ULONG __far __aligned bpen;
  161. int __aligned PlayMode = 2;
  162. int __aligned global_tmp_score=0;
  163. int __aligned previous_score=0;
  164. extern short int ISZERO;
  165. extern int thinkahead;
  166. unsigned long int __aligned next = 1;
  167. int __aligned doswap=0;
  168. int __aligned doundo=0;
  169. int __aligned doauto=0;
  170. int __aligned gfxversion=0L;
  171. int __aligned v15Khz=0L;
  172. int __aligned teston=0;
  173. int __aligned cmptr_sec,cmptr_min,hum_sec,hum_min;
  174. struct TagItem __aligned __far myTagList[8] = {
  175. {SA_DisplayID,VGAPRODUCT_KEY},
  176. {SA_Overscan,OSCAN_STANDARD},
  177. {0,0},
  178. {0,0},
  179. {0,0}
  180. };
  181.  
  182. int __aligned MoveNowOK=0;
  183.  
  184. #define WINDOWSIGNAL (1L<<(wG->UserPort->mp_SigBit))
  185. ULONG __aligned globalsignalset=0L;
  186.  
  187. ULONG __aligned RTG_ModeID=0x0L;
  188. int __aligned Super72=0;
  189. int __aligned RTG=0;
  190. int __aligned SYSTEM_BOBS=1;
  191. int __aligned procpri=3;
  192. struct Process __aligned *myproc;
  193.  
  194. int __aligned __far ResignOffered=0;
  195. //ULONG __far __aligned tmppal[4];
  196.  
  197. inline void TimeCalc (void);
  198.  
  199.  
  200. int __far __aligned FasterDisplay=0;
  201. int __aligned trying_again=0;
  202. int __aligned SupervisorMode=0;
  203. int __aligned MenuStripSet = 0;
  204. int __aligned GlobalTgtDepth=3;
  205.  
  206. UWORD chip myPointer[]={
  207. 0,0,
  208. 31744,0,
  209. 4096,0,
  210. 4096,0,
  211. 4096,0,
  212. 4096,0,
  213. 5120,0,
  214. 5120,0,
  215. 1024,0,
  216. 1920,0,
  217. 1152,0,
  218. 1152,0,
  219. 1152,0,
  220. 256,0,
  221. 0,0,
  222. 768,0,
  223. 256,0,
  224. 256,0,
  225. 256,0,
  226. 896,0,
  227. 0,0,
  228. 896,0,
  229. 576,0,
  230. 576,0,
  231. 576,0,
  232. 576,0,
  233. 0,0,
  234. 512,0,
  235. 512,0,
  236. 576,0,
  237. 640,0,
  238. 896,0,
  239. 640,0,
  240. 576,0,
  241. 0,0,
  242. 256,0,
  243. 0,0,
  244. 768,0,
  245. 256,0,
  246. 256,0,
  247. 256,0,
  248. 896,0,
  249. 0,0,
  250. 0,0,
  251. 896,0,
  252. 576,0,
  253. 576,0,
  254. 576,0,
  255. 576,0,
  256. 0,0,
  257. 960,0,
  258. 576,0,
  259. 576,0,
  260. 960,0,
  261. 64,0,
  262. 960,0,
  263. 0,0
  264. };
  265.  
  266.  
  267. struct TransImage
  268. {
  269.     struct Image *ti_IM;    /* The plain image */
  270.     struct BitMap *ti_sBM;    /* Shadow bitmap */
  271.     struct RastPort *ti_sRP;    /* Shadow rastport */
  272.     struct BitMap ti_BM;    /* Image bitmap */
  273.     struct RastPort ti_RP;    /* Image rastport */
  274. };
  275.  
  276. struct Image __aligned BobImage;
  277.  
  278. struct TransImage __aligned *BobTransImage;
  279.  
  280. struct TransImage *AllocTransImage (struct Image * im);
  281. VOID FreeTransImage (struct TransImage * ti);
  282. VOID ClipBlitTrans (struct RastPort *, WORD, WORD, struct RastPort *, WORD, WORD, WORD, WORD, struct RastPort *);
  283. struct BitMap *AllocShadowBM (UWORD, UWORD, UWORD);
  284. VOID FreeShadowBM (struct BitMap *);
  285. struct RastPort *AllocShadowRP (struct BitMap *);
  286. VOID FreeShadowRP (struct RastPort *);
  287. long __aligned OrigCol,OrigRow,DestCol,DestRow;
  288.  
  289.  
  290. #define TDEPTH 4
  291. #define THEIGHT 400 /* tmp ht */
  292. #define TBLOCKPEN 4 /* was 9 */
  293. #define MENUPEN 11
  294.  
  295. #ifdef EIGHT_BIT_SCREEN
  296. int __aligned DEPTH=8;
  297. #ifdef MANYP
  298. int __aligned HEIGHT=480;
  299. int __aligned USERBOX=168;
  300. int __aligned COMPUTERBOX=60;
  301. int __aligned BACKGNDTEXTCOLOR=0xe0; /* for 256 use 0xe0 */
  302. int __aligned BOBHEIGHT=55; /* 55 for 480 screens */
  303. int __aligned ROW8=24; /* 24 for 480 screens */
  304. int __aligned MBLOCKPEN=251;
  305. #endif
  306. #else
  307. int __aligned DEPTH=4;
  308. #endif
  309.  
  310. int __aligned TCadd = 0;
  311. int __aligned thinking2=0; /* look for move now menu selection in elasped time when set */
  312. int __aligned TIMEYCOORD1=100;
  313. int __aligned TIMEYCOORD2=192;
  314. int __aligned SYSBOXLEN=86;
  315. int __aligned HEIGHT=400;
  316. int __aligned USERBOX=140;
  317. int __aligned SYSTEMBOX=233;
  318. int __aligned COMPUTERBOX=50;
  319. int __aligned BACKGNDTEXTCOLOR=15; /* for 256 use 0xe0 */
  320. int __aligned BOBHEIGHT=46; /* 55 for 480 screens */
  321. int __aligned ROW8=20; /* 24 for 480 screens */
  322. int __aligned MBLOCKPEN=9;
  323.  
  324. #define MENUBARHT 11
  325. #define WIDTH 640
  326. #define VIEWMODES (HIRES|LACE)
  327.  
  328. int __aligned BOBDEPTH=TDEPTH;
  329.  
  330. #define BOARDWIDTH 640
  331. #define BOARDWIDINW 40
  332. #define BOARDSIZE (480*DEPTH*BOARDWIDINW*sizeof(WORD))
  333. #define BOARDBLOCKSIZE ((BOARDSIZE+(BOARDWIDINW*sizeof(WORD))*(480+2))+(BOARDWIDINW*sizeof(WORD)))
  334.  
  335. #define BOBWIDTH 64 /* only 59 pixels are really used, rest are tranparent */
  336. #define BOBWIDINW 4
  337. #define BOBSIZE (BOBHEIGHT*BOBDEPTH*BOBWIDINW*sizeof(WORD))
  338. #define BOBBLOCKSIZE ((BOBSIZE)+(BOBWIDINW*sizeof(WORD)*(BOBHEIGHT+2))+(BOBWIDINW*sizeof(WORD)))
  339.  
  340. #define BOBLW ((BOBBLOCKSIZE)/4)
  341. #define BOBMEMASK 0
  342. #define BOBHITMASK 0
  343. int __aligned BOBPLANEPICK=0xf; /* if 16 colors should be 0xf if 256 should be 0xff */
  344. #define BOBPLANEONOFF 0x0
  345.  
  346. #define SQUAREWIDTH 59
  347. #define ROUNDEDSQUAREWIDTH 64
  348. #define SQUAREHEIGHT BOBHEIGHT
  349. #define COLA (16)
  350. #define COLB (16+SQUAREWIDTH)
  351. #define COLC (16+SQUAREWIDTH*2)
  352. #define COLD (16+SQUAREWIDTH*3)
  353. #define COLE (16+SQUAREWIDTH*4)
  354. #define COLF (16+SQUAREWIDTH*5)
  355. #define COLG (16+SQUAREWIDTH*6)
  356. #define COLH (16+SQUAREWIDTH*7)
  357. #define ROW7 (ROW8+SQUAREHEIGHT)
  358. #define ROW6 (ROW8+SQUAREHEIGHT*2)
  359. #define ROW5 (ROW8+SQUAREHEIGHT*3)
  360. #define ROW4 (ROW8+SQUAREHEIGHT*4)
  361. #define ROW3 (ROW8+SQUAREHEIGHT*5)
  362. #define ROW2 (ROW8+SQUAREHEIGHT*6)
  363. #define ROW1 (ROW8+SQUAREHEIGHT*7)
  364.  
  365.  
  366. UWORD __aligned *BlankImageData;
  367.  
  368. UWORD __far __aligned *WhiteImageData[6];
  369. UWORD __far __aligned *BlackImageData[6];
  370.  
  371. void LoadBobImage(long);
  372.  
  373. long __far __aligned ColArray[8]={COLA,COLB,COLC,COLD,COLE,COLF,COLG,COLH};
  374. long __far __aligned RowArray[8];
  375.  
  376. struct VSprite __aligned *SpriteHead;
  377. struct VSprite __aligned *SpriteTail;
  378.  
  379. struct GelsInfo __aligned *myGelsInfo;
  380. struct VSprite __aligned *BobVSprite;
  381. struct Bob __aligned *TheBob;
  382.  
  383. struct BitMap __aligned *WhiteBitMap,*BlackBitMap;
  384. struct BitMap *textBitMap=(struct BitMap *)0L;
  385.  
  386. struct TextFont __aligned *myTextFont;
  387.  
  388. extern struct GfxBase __aligned *Gfxbase;
  389. long __aligned __stack=50000L;
  390. ULONG tt;
  391. struct RastPort __aligned *rpG;
  392. struct ViewPort __aligned *vP;
  393. struct Screen __aligned *sC=0L;
  394. struct Window __aligned *wG=0L;
  395. struct Window __aligned *wGEdit;
  396. unsigned char __far __aligned cookedchar[128]={'~',
  397.                   '1',
  398.                   '2',
  399.                   '3',
  400.                   '4',
  401.                   '5',
  402.                   '6',
  403.                   '7',
  404.                   '8',
  405.                   '9',
  406.                   '0', /* 10 */
  407.                   '-',
  408.                   '=',
  409.                   ' ',
  410.                   ' ',
  411.                   '0',
  412.                   'Q', /* 16 */
  413.                   'W',
  414.                   'E',
  415.                   'R',
  416.                   'T', /* 20 */
  417.                   'Y',
  418.                   'U',
  419.                   'I',
  420.                   'O',
  421.                   'P', /* 25 */
  422.                   '[',
  423.                   ']',
  424.                   ' ',
  425.                   '1',
  426.                   '2',
  427.                   '3',
  428.                   'A',
  429.                   'S',
  430.                   'D',
  431.                   'F',
  432.                   'G',
  433.                   'H',
  434.                   'J',
  435.                   'K',
  436.                   'L', /* 40 */
  437.                   ':',
  438.                   '"',
  439.                   13,
  440.                   ' ',
  441.                   '4',
  442.                   '5',
  443.                   '6',
  444.                   ' ',
  445.                   'Z',
  446.                   'X', /* 50 */
  447.                   'C',
  448.                   'V',
  449.                   'B',
  450.                   'N',
  451.                   'M', /* 55 */
  452.                   ',',
  453.                   '.',
  454.                   '/',
  455.                   ' ',
  456.                   '.',
  457.                   '7',
  458.                   '8',
  459.                   '9',
  460.                   ' ',
  461.                   7,
  462.                   8,
  463.                   13,
  464.                   13,
  465.                   27,
  466.                   7
  467. };
  468.  
  469.  
  470.  
  471.  
  472. char __aligned *Orig_PlanePtr;
  473. struct BitMap __aligned *myBitMap;
  474. struct BitMap __aligned *OrigmyBitMap=0L;
  475.  
  476. #include "Chess256Palette.c"
  477.  
  478. UWORD __far __aligned myPalette[16]=
  479. {
  480. 0xfbc, 0x632, 0x455, 0x842, 0x549, 0xa53, 0x787, 0xa56, 
  481. 0x967, 0xa85, 0x3ab, 0xaaa, 0xe88, 0xdb8, 0x333, 0xeee
  482. };
  483.  
  484. #ifdef OLDPAL
  485. {
  486. 0x0, 0x222, 0x410, 0x333, 
  487. 0x621, 0x624, 0x952, 0x665, 
  488. 0x974, 0x887, 0xb85, 0xaa9, 
  489. 0xbb7, 0xcc8, 0xcc9, 0xddc};
  490. #endif 
  491.  
  492. struct TextAttr __far __aligned TOPAZ80 = {
  493.     (STRPTR)"topaz.font",
  494.     TOPAZ_EIGHTY,0,0
  495. };
  496.  
  497. SHORT __far __aligned BorderVectors6[] = {
  498.     0,0,
  499.     44,0,
  500.     44,19,
  501.     0,19,
  502.     0,0
  503. };
  504. struct Border __far __aligned Border6 = {
  505.     -1,-1,    /* XY origin relative to container TopLeft */
  506.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  507.     5,    /* number of XY vectors */
  508.     BorderVectors6,    /* pointer to XY vectors */
  509.     NULL    /* next border in list */
  510. };
  511.  
  512. struct IntuiText __far __aligned IText93 = {
  513.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  514.     12,6,    /* XY origin relative to container TopLeft */
  515.     NULL,    /* font pointer or NULL for default */
  516.     "OK",    /* pointer to text */
  517.     NULL    /* next IntuiText structure */
  518. };
  519.  
  520. struct Gadget __far __aligned Gadget9 = {
  521.     NULL,    /* next gadget */
  522.     109,64,    /* origin XY of hit box relative to window TopLeft */
  523.     43,18,    /* hit box width and height */
  524.     NULL,    /* gadget flags */
  525.     RELVERIFY,    /* activation flags */
  526.     BOOLGADGET,    /* gadget type flags */
  527.     (APTR)&Border6,    /* gadget border or image to be rendered */
  528.     NULL,    /* alternate imagery for selection */
  529.     &IText93,    /* first IntuiText structure */
  530.     NULL,    /* gadget mutual-exclude long word */
  531.     NULL,    /* SpecialInfo structure */
  532.     NULL,    /* user-definable data */
  533.     NULL    /* pointer to user-definable data */
  534. };
  535.  
  536. UBYTE __aligned Gadget8SIBuff[8];
  537. struct StringInfo __aligned Gadget8SInfo = {
  538.     Gadget8SIBuff,    /* buffer where text will be edited */
  539.     NULL,    /* optional undo buffer */
  540.     0,    /* character position in buffer */
  541.     5,    /* maximum number of characters to allow */
  542.     0,    /* first displayed character buffer position */
  543.     0,0,0,0,0,    /* Intuition initialized and maintained variables */
  544.     0,    /* Rastport of gadget */
  545.     0,    /* initial value for integer gadgets */
  546.     NULL    /* alternate keymap (fill in if you set the flag) */
  547. };
  548.  
  549. SHORT __far __aligned BorderVectors7[] = {
  550.     0,0,
  551.     45,0 /* was 45 */,
  552.     45,14, /* was 17 */
  553.     0,14,
  554.     0,0
  555. };
  556. struct Border __far __aligned Border7 = {
  557.     -1,-1,    /* XY origin relative to container TopLeft */
  558.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  559.     5,    /* number of XY vectors */
  560.     BorderVectors7,    /* pointer to XY vectors */
  561.     NULL    /* next border in list */
  562. };
  563.  
  564. struct Gadget __far __aligned Gadget8 = {
  565.     &Gadget9,    /* next gadget */
  566.     136,32,    /* origin XY of hit box relative to window TopLeft */
  567.     44,16,    /* hit box width and height */
  568.     NULL,    /* gadget flags */
  569.     RELVERIFY,    /* activation flags */
  570.     STRGADGET,    /* gadget type flags */
  571.     (APTR)&Border7,    /* gadget border or image to be rendered */
  572.     NULL,    /* alternate imagery for selection */
  573.     NULL,    /* first IntuiText structure */
  574.     NULL,    /* gadget mutual-exclude long word */
  575.     (APTR)&Gadget8SInfo,    /* SpecialInfo structure */
  576.     NULL,    /* user-definable data */
  577.     NULL    /* pointer to user-definable data */
  578. };
  579.  
  580.  
  581. UBYTE __aligned Gadget6SIBuff[8];
  582. struct StringInfo __aligned Gadget6SInfo = {
  583.     Gadget6SIBuff,    /* buffer where text will be edited */
  584.     NULL,    /* optional undo buffer */
  585.     0,    /* character position in buffer */
  586.     4,    /* maximum number of characters to allow */
  587.     0,    /* first displayed character buffer position */
  588.     0,0,0,0,0,    /* Intuition initialized and maintained variables */
  589.     0,    /* Rastport of gadget */
  590.     0,    /* initial value for integer gadgets */
  591.     NULL    /* alternate keymap (fill in if you set the flag) */
  592. };
  593.  
  594. struct Border __far __aligned Border9 = {
  595.     -1,-1,    /* XY origin relative to container TopLeft */
  596.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  597.     5,    /* number of XY vectors */
  598.     BorderVectors7,    /* pointer to XY vectors */
  599.     NULL    /* next border in list */
  600. };
  601.  
  602. struct Gadget __far __aligned Gadget6 = {
  603.     &Gadget8,    /* next gadget */
  604.     14,32,    /* origin XY of hit box relative to window TopLeft */
  605.     44,16,    /* hit box width and height */
  606.     NULL,    /* gadget flags */
  607.     RELVERIFY,    /* activation flags */
  608.     STRGADGET,    /* gadget type flags */
  609.     (APTR)&Border9,    /* gadget border or image to be rendered */
  610.     NULL,    /* alternate imagery for selection */
  611.     NULL,    /* first IntuiText structure */
  612.     NULL,    /* gadget mutual-exclude long word */
  613.     (APTR)&Gadget6SInfo,    /* SpecialInfo structure */
  614.     NULL,    /* user-definable data */
  615.     NULL    /* pointer to user-definable data */
  616. };
  617.  
  618. struct Gadget __far __aligned Gadget6b = {
  619.     &Gadget9,    /* next gadget */
  620.     14,32,    /* origin XY of hit box relative to window TopLeft */
  621.     44,16,    /* hit box width and height */
  622.     NULL,    /* gadget flags */
  623.     RELVERIFY,    /* activation flags */
  624.     STRGADGET,    /* gadget type flags */
  625.     (APTR)&Border9,    /* gadget border or image to be rendered */
  626.     NULL,    /* alternate imagery for selection */
  627.     NULL,    /* first IntuiText structure */
  628.     NULL,    /* gadget mutual-exclude long word */
  629.     (APTR)&Gadget6SInfo,    /* SpecialInfo structure */
  630.     NULL,    /* user-definable data */
  631.     NULL    /* pointer to user-definable data */
  632. };
  633.  
  634.  
  635.  
  636.  
  637. struct IntuiText __aligned IText47 = {
  638.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  639.     195,36,    /* XY origin relative to container TopLeft */
  640.     NULL,    /* font pointer or NULL for default */
  641.     "Minutes.",    /* pointer to text */
  642.     NULL    /* next IntuiText structure */
  643. };
  644.  
  645. struct IntuiText __far __aligned IText46 = {
  646.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  647.     64,35,    /* XY origin relative to container TopLeft */
  648.     NULL,    /* font pointer or NULL for default */
  649.     "Moves in",    /* pointer to text */
  650.     &IText47    /* next IntuiText structure */
  651. };
  652.  
  653. #define IntuiTextList5 IText46
  654.  
  655. struct NewWindow __far __aligned NewWindowStructure5 = {
  656.     161,23,    /* window XY origin relative to TopLeft of screen */
  657.     270,90,    /* window width and height */
  658.     0,TBLOCKPEN,    /* detail and block pens */
  659.     GADGETUP,    /* IDCMP flags */
  660.     SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  661.     &Gadget6,    /* first gadget in gadget list */
  662.     NULL,    /* custom CHECKMARK imagery */
  663.     "Computer Time Ctrl",    /* window title */
  664.     NULL,    /* custom screen pointer */
  665.     NULL,    /* custom bitmap */
  666.     5,5,    /* minimum width and height */
  667.     0xffff,0xffff,    /* maximum width and height */
  668.     CUSTOMSCREEN    /* destination screen type */
  669. };
  670.  
  671.  
  672. struct ExtNewScreen __far __aligned NewScreenStructure = {
  673.     0,0,    /* screen XY origin relative to View */
  674.     WIDTH,THEIGHT,    /* screen width and height */
  675.     4,    /* screen depth (number of bitplanes) */
  676.     0,TBLOCKPEN,    /* detail and block pens */
  677.     VIEWMODES,    /* display modes for this screen */
  678.     CUSTOMBITMAP|CUSTOMSCREEN,    /* screen type */
  679.     &TOPAZ80,    /* pointer to default screen font */
  680.     VERSTRING,    /* screen title */
  681.     NULL,    /* first in list of custom screen gadgets */
  682.     NULL    /* pointer to custom BitMap structure */
  683. };
  684.  
  685. struct ExtNewScreen __far __aligned NewScreenStructure2 = {
  686.     0,0,    /* screen XY origin relative to View */
  687.     WIDTH,480,    /* screen width and height */
  688.     8,    /* screen depth (number of bitplanes) */
  689.     0,251,    /* detail and block pens */
  690.     VIEWMODES,    /* display modes for this screen */
  691.     CUSTOMSCREEN|SCREENBEHIND,    /* screen type */
  692.     &TOPAZ80,    /* pointer to default screen font */
  693.     " ",    /* screen title */
  694.     NULL,    /* first in list of custom screen gadgets */
  695.     NULL    /* pointer to custom BitMap structure */
  696. };
  697.  
  698.  
  699. struct IntuiText __far __aligned IText37 = {
  700.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  701.     0,0,    /* XY origin relative to container TopLeft */
  702.     &TOPAZ80,    /* font pointer or NULL for default */
  703.     "New Game",    /* pointer to text */
  704.     NULL    /* next IntuiText structure */
  705. };
  706.  
  707. struct IntuiText __far __aligned IText1r = {
  708.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  709.     0,0,    /* XY origin relative to container TopLeft */
  710.     &TOPAZ80,    /* font pointer or NULL for default */
  711.     "Set Depth",    /* pointer to text */
  712.     NULL    /* next IntuiText structure */
  713. };
  714.  
  715. struct MenuItem __aligned MenuItem3r = {
  716.     NULL,    /* next MenuItem structure */
  717.     0,32,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  718.     72,8,    /* hit box width and height */
  719.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  720.     0,    /* each bit mutually-excludes a same-level Item */
  721.     (APTR)&IText1r,    /* Item render  (IntuiText or Image or NULL) */
  722.     NULL,    /* Select render */
  723.     NULL,    /* alternate command-key */
  724.     NULL,    /* SubItem list */
  725.     MENUNULL    /* filled in by Intuition for drag selections */
  726. };
  727.  
  728. struct IntuiText __far __aligned IText1 = {
  729.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  730.     0,0,    /* XY origin relative to container TopLeft */
  731.     &TOPAZ80,    /* font pointer or NULL for default */
  732.     "Set Time",    /* pointer to text */
  733.     NULL    /* next IntuiText structure */
  734. };
  735.  
  736. struct MenuItem __aligned MenuItem3 = {
  737.     &MenuItem3r,    /* next MenuItem structure */
  738.     0,24,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  739.     72,8,    /* hit box width and height */
  740.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  741.     0,    /* each bit mutually-excludes a same-level Item */
  742.     (APTR)&IText1,    /* Item render  (IntuiText or Image or NULL) */
  743.     NULL,    /* Select render */
  744.     NULL,    /* alternate command-key */
  745.     NULL,    /* SubItem list */
  746.     MENUNULL    /* filled in by Intuition for drag selections */
  747. };
  748.  
  749. struct IntuiText __far __aligned IText2x = {
  750.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  751.     0,0,    /* XY origin relative to container TopLeft */
  752.     &TOPAZ80,    /* font pointer or NULL for default */
  753.     "Rate Pgm",    /* pointer to text */
  754.     NULL    /* next IntuiText structure */
  755. };
  756.  
  757. struct MenuItem __aligned MenuItem3x = {
  758.     &MenuItem3,    /* next MenuItem structure */
  759.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  760.     72,8,    /* hit box width and height */
  761.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  762.     0,    /* each bit mutually-excludes a same-level Item */
  763.     (APTR)&IText2x,    /* Item render  (IntuiText or Image or NULL) */
  764.     NULL,    /* Select render */
  765.     NULL,    /* alternate command-key */
  766.     NULL,    /* SubItem list */
  767.     MENUNULL    /* filled in by Intuition for drag selections */
  768. };
  769.  
  770. struct IntuiText __far __aligned IText2 = {
  771.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  772.     0,0,    /* XY origin relative to container TopLeft */
  773.     &TOPAZ80,    /* font pointer or NULL for default */
  774.     "Test",    /* pointer to text */
  775.     NULL    /* next IntuiText structure */
  776. };
  777.  
  778. struct MenuItem __aligned MenuItem2 = {
  779.     &MenuItem3x,    /* next MenuItem structure */
  780.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  781.     72,8,    /* hit box width and height */
  782.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  783.     0,    /* each bit mutually-excludes a same-level Item */
  784.     (APTR)&IText2,    /* Item render  (IntuiText or Image or NULL) */
  785.     NULL,    /* Select render */
  786.     NULL,    /* alternate command-key */
  787.     NULL,    /* SubItem list */
  788.     MENUNULL    /* filled in by Intuition for drag selections */
  789. };
  790.  
  791. struct IntuiText __far __aligned IText3 = {
  792.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  793.     0,0,    /* XY origin relative to container TopLeft */
  794.     &TOPAZ80,    /* font pointer or NULL for default */
  795.     "Hint",    /* pointer to text */
  796.     NULL    /* next IntuiText structure */
  797. };
  798.  
  799. struct MenuItem __aligned MenuItem1 = {
  800.     &MenuItem2,    /* next MenuItem structure */
  801.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  802.     72,8,    /* hit box width and height */
  803.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  804.     0,    /* each bit mutually-excludes a same-level Item */
  805.     (APTR)&IText3,    /* Item render  (IntuiText or Image or NULL) */
  806.     NULL,    /* Select render */
  807.     'H',    /* alternate command-key */
  808.     NULL,    /* SubItem list */
  809.     MENUNULL    /* filled in by Intuition for drag selections */
  810. };
  811.  
  812. struct Menu __aligned Menu4 = {
  813.     NULL,    /* next Menu structure */
  814.     162,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  815.     63,0,    /* Menu hit box width and height */
  816.     MENUENABLED,    /* Menu flags */
  817.     "Special",    /* text of Menu name */
  818.     &MenuItem1    /* MenuItem linked list pointer */
  819. };
  820.  
  821. struct IntuiText __far __aligned IText4cc = {
  822.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  823.     19,0,    /* XY origin relative to container TopLeft */
  824.     &TOPAZ80,    /* font pointer or NULL for default */
  825.     "Easy",    /* pointer to text */
  826.     NULL    /* next IntuiText structure */
  827. };
  828.  
  829. struct MenuItem __aligned MenuItem8cc = {
  830.     NULL,    /* next MenuItem structure */
  831.     0,80,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  832.     123,8,    /* hit box width and height */
  833.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  834.     EXCLUDE_PATT^(0x400),    /* each bit mutually-excludes a same-level Item */
  835.     (APTR)&IText4cc,    /* Item render  (IntuiText or Image or NULL) */
  836.     NULL,    /* Select render */
  837.     'E',    /* alternate command-key */
  838.     NULL,    /* SubItem list */
  839.     MENUNULL    /* filled in by Intuition for drag selections */
  840. };
  841.  
  842. struct IntuiText __far __aligned IText4dd = {
  843.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  844.     19,0,    /* XY origin relative to container TopLeft */
  845.     &TOPAZ80,    /* font pointer or NULL for default */
  846.     "Intrmdt",    /* pointer to text */
  847.     NULL    /* next IntuiText structure */
  848. };
  849.  
  850. struct MenuItem __aligned MenuItem8dd = {
  851.     &MenuItem8cc,    /* next MenuItem structure */
  852.     0,72,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  853.     123,8,    /* hit box width and height */
  854.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  855.     EXCLUDE_PATT^(0x200),    /* each bit mutually-excludes a same-level Item */
  856.     (APTR)&IText4dd,    /* Item render  (IntuiText or Image or NULL) */
  857.     NULL,    /* Select render */
  858.     'I',    /* alternate command-key */
  859.     NULL,    /* SubItem list */
  860.     MENUNULL    /* filled in by Intuition for drag selections */
  861. };
  862.  
  863. struct IntuiText __far __aligned IText4ee = {
  864.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  865.     19,0,    /* XY origin relative to container TopLeft */
  866.     &TOPAZ80,    /* font pointer or NULL for default */
  867.     "Advancd",    /* pointer to text */
  868.     NULL    /* next IntuiText structure */
  869. };
  870.  
  871. struct MenuItem __aligned MenuItem8ee = {
  872.     &MenuItem8dd,    /* next MenuItem structure */
  873.     0,64,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  874.     123,8,    /* hit box width and height */
  875.     CHECKED+CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+HIGHCOMP,    /* Item flags */
  876.     EXCLUDE_PATT^(0x100),    /* each bit mutually-excludes a same-level Item */
  877.     (APTR)&IText4ee,    /* Item render  (IntuiText or Image or NULL) */
  878.     NULL,    /* Select render */
  879.     'A',    /* alternate command-key */
  880.     NULL,    /* SubItem list */
  881.     MENUNULL    /* filled in by Intuition for drag selections */
  882. };
  883.  
  884. struct IntuiText __far __aligned IText4aa = {
  885.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  886.     19,0,    /* XY origin relative to container TopLeft */
  887.     &TOPAZ80,    /* font pointer or NULL for default */
  888.     "Supvsr",    /* pointer to text */
  889.     NULL    /* next IntuiText structure */
  890. };
  891.  
  892. struct MenuItem __aligned MenuItem8aa = {
  893.     &MenuItem8ee,    /* next MenuItem structure */
  894.     0,56,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  895.     123,8,    /* hit box width and height */
  896.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  897.     0,    /* each bit mutually-excludes a same-level Item */
  898.     (APTR)&IText4aa,    /* Item render  (IntuiText or Image or NULL) */
  899.     NULL,    /* Select render */
  900.     'Y',    /* alternate command-key */
  901.     NULL,    /* SubItem list */
  902.     MENUNULL    /* filled in by Intuition for drag selections */
  903. };
  904.  
  905. struct IntuiText __far __aligned IText4ab = {
  906.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  907.     19,0,    /* XY origin relative to container TopLeft */
  908.     &TOPAZ80,    /* font pointer or NULL for default */
  909.     "Book",    /* pointer to text */
  910.     NULL    /* next IntuiText structure */
  911. };
  912.  
  913. struct MenuItem __aligned MenuItem8ab = {
  914.       &MenuItem8aa,    /* next MenuItem structure */
  915.     0,48,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  916.     123,8,    /* hit box width and height */
  917.     CHECKIT+CHECKED+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  918.     0,    /* each bit mutually-excludes a same-level Item */
  919.     (APTR)&IText4ab,    /* Item render  (IntuiText or Image or NULL) */
  920.     NULL,    /* Select render */
  921.     'B',    /* alternate command-key */
  922.     NULL,    /* SubItem list */
  923.     MENUNULL    /* filled in by Intuition for drag selections */
  924. };
  925.  
  926. struct IntuiText __far __aligned IText4a = {
  927.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  928.     19,0,    /* XY origin relative to container TopLeft */
  929.     &TOPAZ80,    /* font pointer or NULL for default */
  930.     "ShwThnk",    /* pointer to text */
  931.     NULL    /* next IntuiText structure */
  932. };
  933.  
  934. struct MenuItem __aligned MenuItem8a = {
  935.     &MenuItem8ab,    /* next MenuItem structure */
  936.     0,40,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  937.     123,8,    /* hit box width and height */
  938.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  939.     0,    /* each bit mutually-excludes a same-level Item */
  940.     (APTR)&IText4a,    /* Item render  (IntuiText or Image or NULL) */
  941.     NULL,    /* Select render */
  942.     'V',    /* alternate command-key */
  943.     NULL,    /* SubItem list */
  944.     MENUNULL    /* filled in by Intuition for drag selections */
  945. };
  946.  
  947. struct IntuiText __far __aligned IText4 = {
  948.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  949.     19,0,    /* XY origin relative to container TopLeft */
  950.     &TOPAZ80,    /* font pointer or NULL for default */
  951.     "Thinking",    /* pointer to text */
  952.     NULL    /* next IntuiText structure */
  953. };
  954.  
  955. struct MenuItem __aligned MenuItem8 = {
  956.     &MenuItem8a,    /* next MenuItem structure */
  957.     0,32,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  958.     123,8,    /* hit box width and height */
  959.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ/*+ITEMENABLED*/+HIGHCOMP,    /* Item flags */
  960.     0,    /* each bit mutually-excludes a same-level Item */
  961.     (APTR)&IText4,    /* Item render  (IntuiText or Image or NULL) */
  962.     NULL,    /* Select render */
  963.     'T',    /* alternate command-key */
  964.     NULL,    /* SubItem list */
  965.     MENUNULL    /* filled in by Intuition for drag selections */
  966. };
  967.  
  968. struct IntuiText __far __aligned IText5 = {
  969.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  970.     0,0,    /* XY origin relative to container TopLeft */
  971.     &TOPAZ80,    /* font pointer or NULL for default */
  972.     "Undo",    /* pointer to text */
  973.     NULL    /* next IntuiText structure */
  974. };
  975.  
  976. struct MenuItem __aligned MenuItem7 = {
  977.     &MenuItem8,    /* next MenuItem structure */
  978.     0,24,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  979.     123,8,    /* hit box width and height */
  980.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  981.     0,    /* each bit mutually-excludes a same-level Item */
  982.     (APTR)&IText5,    /* Item render  (IntuiText or Image or NULL) */
  983.     NULL,    /* Select render */
  984.     'U',    /* alternate command-key */
  985.     NULL,    /* SubItem list */
  986.     MENUNULL    /* filled in by Intuition for drag selections */
  987. };
  988.  
  989. struct IntuiText __far __aligned IText6 = {
  990.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  991.     0,0,    /* XY origin relative to container TopLeft */
  992.     &TOPAZ80,    /* font pointer or NULL for default */
  993.     "Move Now",    /* pointer to text */
  994.     NULL    /* next IntuiText structure */
  995. };
  996.  
  997. struct MenuItem __aligned MenuItem6 = {
  998.     &MenuItem7,    /* next MenuItem structure */
  999.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1000.     123,8,    /* hit box width and height */
  1001.     ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  1002.     0,    /* each bit mutually-excludes a same-level Item */
  1003.     (APTR)&IText6,    /* Item render  (IntuiText or Image or NULL) */
  1004.     NULL,    /* Select render */
  1005.     'M',    /* alternate command-key */
  1006.     NULL,    /* SubItem list */
  1007.     MENUNULL    /* filled in by Intuition for drag selections */
  1008. };
  1009.  
  1010. struct IntuiText __far __aligned IText7 = {
  1011.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1012.     0,0,    /* XY origin relative to container TopLeft */
  1013.     &TOPAZ80,    /* font pointer or NULL for default */
  1014.     "AutoPlay",    /* pointer to text */
  1015.     NULL    /* next IntuiText structure */
  1016. };
  1017.  
  1018. struct MenuItem __aligned MenuItem5 = {
  1019.     &MenuItem6,    /* next MenuItem structure */
  1020.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1021.     123,8,    /* hit box width and height */
  1022.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1023.     0,    /* each bit mutually-excludes a same-level Item */
  1024.     (APTR)&IText7,    /* Item render  (IntuiText or Image or NULL) */
  1025.     NULL,    /* Select render */
  1026.     NULL,    /* alternate command-key */
  1027.     NULL,    /* SubItem list */
  1028.     MENUNULL    /* filled in by Intuition for drag selections */
  1029. };
  1030.  
  1031. struct IntuiText __far __aligned IText8 = {
  1032.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1033.     0,0,    /* XY origin relative to container TopLeft */
  1034.     &TOPAZ80,    /* font pointer or NULL for default */
  1035.     "Swap Sides",    /* pointer to text */
  1036.     NULL    /* next IntuiText structure */
  1037. };
  1038.  
  1039. struct MenuItem __aligned MenuItem4 = {
  1040.     &MenuItem5,    /* next MenuItem structure */
  1041.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1042.     123,8,    /* hit box width and height */
  1043.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1044.     0,    /* each bit mutually-excludes a same-level Item */
  1045.     (APTR)&IText8,    /* Item render  (IntuiText or Image or NULL) */
  1046.     NULL,    /* Select render */
  1047.     'S',    /* alternate command-key */
  1048.     NULL,    /* SubItem list */
  1049.     MENUNULL    /* filled in by Intuition for drag selections */
  1050. };
  1051.  
  1052. struct Menu __aligned Menu3 = {
  1053.     &Menu4,    /* next Menu structure */
  1054.     92,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  1055.     63,0,    /* Menu hit box width and height */
  1056.     MENUENABLED,    /* Menu flags */
  1057.     "Control",    /* text of Menu name */
  1058.     &MenuItem4    /* MenuItem linked list pointer */
  1059. };
  1060.  
  1061. struct IntuiText __far __aligned IText9 = {
  1062.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1063.     0,0,    /* XY origin relative to container TopLeft */
  1064.     &TOPAZ80,    /* font pointer or NULL for default */
  1065.     "ReverseBoard",    /* pointer to text */
  1066.     NULL    /* next IntuiText structure */
  1067. };
  1068.  
  1069. struct MenuItem __aligned MenuItem11 = {
  1070.     NULL,    /* next MenuItem structure */
  1071.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1072.     96,8,    /* hit box width and height */
  1073.     ITEMTEXT+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  1074.     0,    /* each bit mutually-excludes a same-level Item */
  1075.     (APTR)&IText9,    /* Item render  (IntuiText or Image or NULL) */
  1076.     NULL,    /* Select render */
  1077.     NULL,    /* alternate command-key */
  1078.     NULL,    /* SubItem list */
  1079.     MENUNULL    /* filled in by Intuition for drag selections */
  1080. };
  1081.  
  1082. struct IntuiText __far __aligned IText10 = {
  1083.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1084.     19,0,    /* XY origin relative to container TopLeft */
  1085.     &TOPAZ80,    /* font pointer or NULL for default */
  1086.     "Edit Board",    /* pointer to text */
  1087.     NULL    /* next IntuiText structure */
  1088. };
  1089.  
  1090. struct MenuItem __aligned MenuItem10 = {
  1091.     &MenuItem11,    /* next MenuItem structure */
  1092.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1093.     96,8,    /* hit box width and height */
  1094.     ITEMTEXT+HIGHCOMP+ITEMENABLED,    /* Item flags */
  1095.     0,    /* each bit mutually-excludes a same-level Item */
  1096.     (APTR)&IText10,    /* Item render  (IntuiText or Image or NULL) */
  1097.     NULL,    /* Select render */
  1098.     NULL,    /* alternate command-key */
  1099.     NULL,    /* SubItem list */
  1100.     MENUNULL    /* filled in by Intuition for drag selections */
  1101. };
  1102.  
  1103. struct IntuiText __far __aligned IText11 = {
  1104.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1105.     19,0,    /* XY origin relative to container TopLeft */
  1106.     &TOPAZ80,    /* font pointer or NULL for default */
  1107.     "2-D",    /* pointer to text */
  1108.     NULL    /* next IntuiText structure */
  1109. };
  1110.  
  1111. struct MenuItem __aligned MenuItem9 = {
  1112.     &MenuItem10,    /* next MenuItem structure */
  1113.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1114.     96,8,    /* hit box width and height */
  1115.     CHECKED+CHECKIT+ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1116.     0,    /* each bit mutually-excludes a same-level Item */
  1117.     (APTR)&IText11,    /* Item render  (IntuiText or Image or NULL) */
  1118.     NULL,    /* Select render */
  1119.     NULL,    /* alternate command-key */
  1120.     NULL,    /* SubItem list */
  1121.     MENUNULL    /* filled in by Intuition for drag selections */
  1122. };
  1123.  
  1124. struct Menu __aligned Menu2 = {
  1125.     &Menu3,    /* next Menu structure */
  1126.     46,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  1127.     39,0,    /* Menu hit box width and height */
  1128.     MENUENABLED,    /* Menu flags */
  1129.     "View",    /* text of Menu name */
  1130.     &MenuItem9    /* MenuItem linked list pointer */
  1131. };
  1132.  
  1133. struct IntuiText __far __aligned IText12 = {
  1134.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1135.     0,0,    /* XY origin relative to container TopLeft */
  1136.     &TOPAZ80,    /* font pointer or NULL for default */
  1137.     "Quit",    /* pointer to text */
  1138.     NULL    /* next IntuiText structure */
  1139. };
  1140.  
  1141. struct MenuItem __aligned MenuItem15 = {
  1142.     NULL,    /* next MenuItem structure */
  1143.     0,40,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1144.     72,8,    /* hit box width and height */
  1145.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1146.     0,    /* each bit mutually-excludes a same-level Item */
  1147.     (APTR)&IText12,    /* Item render  (IntuiText or Image or NULL) */
  1148.     NULL,    /* Select render */
  1149.     'Q',    /* alternate command-key */
  1150.     NULL,    /* SubItem list */
  1151.     MENUNULL    /* filled in by Intuition for drag selections */
  1152. };
  1153.  
  1154. struct IntuiText __far __aligned IText13a = {
  1155.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1156.     0,0,    /* XY origin relative to container TopLeft */
  1157.     &TOPAZ80,    /* font pointer or NULL for default */
  1158.     "List Game",    /* pointer to text */
  1159.     NULL    /* next IntuiText structure */
  1160. };
  1161.  
  1162. struct MenuItem __aligned MenuItem14a = {
  1163.     &MenuItem15,    /* next MenuItem structure */
  1164.     0,32,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1165.     72,8,    /* hit box width and height */
  1166.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1167.     0,    /* each bit mutually-excludes a same-level Item */
  1168.     (APTR)&IText13a,/* Item render  (IntuiText or Image or NULL) */
  1169.     NULL,    /* Select render */
  1170.     NULL,    /* alternate command-key */
  1171.     NULL,    /* SubItem list */
  1172.     MENUNULL    /* filled in by Intuition for drag selections */
  1173. };
  1174.  
  1175. struct IntuiText __far __aligned IText13 = {
  1176.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1177.     0,0,    /* XY origin relative to container TopLeft */
  1178.     &TOPAZ80,    /* font pointer or NULL for default */
  1179.     "Save Game",    /* pointer to text */
  1180.     NULL    /* next IntuiText structure */
  1181. };
  1182.  
  1183. struct MenuItem __aligned MenuItem14 = {
  1184.     &MenuItem14a,    /* next MenuItem structure */
  1185.     0,24,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1186.     72,8,    /* hit box width and height */
  1187.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1188.     0,    /* each bit mutually-excludes a same-level Item */
  1189.     (APTR)&IText13,    /* Item render  (IntuiText or Image or NULL) */
  1190.     NULL,    /* Select render */
  1191.     NULL,    /* alternate command-key */
  1192.     NULL,    /* SubItem list */
  1193.     MENUNULL    /* filled in by Intuition for drag selections */
  1194. };
  1195.  
  1196. struct IntuiText __far __aligned IText14 = {
  1197.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1198.     0,0,    /* XY origin relative to container TopLeft */
  1199.     &TOPAZ80,    /* font pointer or NULL for default */
  1200.     "Load Game",    /* pointer to text */
  1201.     NULL    /* next IntuiText structure */
  1202. };
  1203.  
  1204. struct MenuItem __aligned MenuItem13 = {
  1205.     &MenuItem14,    /* next MenuItem structure */
  1206.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1207.     72,8,    /* hit box width and height */
  1208.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1209.     0,    /* each bit mutually-excludes a same-level Item */
  1210.     (APTR)&IText14,    /* Item render  (IntuiText or Image or NULL) */
  1211.     NULL,    /* Select render */
  1212.     NULL,    /* alternate command-key */
  1213.     NULL,    /* SubItem list */
  1214.     MENUNULL    /* filled in by Intuition for drag selections */
  1215. };
  1216.  
  1217. struct MenuItem __aligned MenuItem28 = {
  1218.     &MenuItem13,    /* next MenuItem structure */
  1219.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1220.     72,8,    /* hit box width and height */
  1221.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1222.     0,    /* each bit mutually-excludes a same-level Item */
  1223.     (APTR)&IText37,    /* Item render  (IntuiText or Image or NULL) */
  1224.     NULL,    /* Select render */
  1225.     NULL,    /* alternate command-key */
  1226.     NULL,    /* SubItem list */
  1227.     MENUNULL    /* filled in by Intuition for drag selections */
  1228. };
  1229.  
  1230. struct IntuiText __far __aligned IText15 = {
  1231.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1232.     0,0,    /* XY origin relative to container TopLeft */
  1233.     &TOPAZ80,    /* font pointer or NULL for default */
  1234.     "About..",    /* pointer to text */
  1235.     NULL    /* next IntuiText structure */
  1236. };
  1237.  
  1238. struct MenuItem __aligned MenuItem12 = {
  1239.     &MenuItem28,    /* next MenuItem structure */
  1240.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1241.     72,8,    /* hit box width and height */
  1242.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1243.     0,    /* each bit mutually-excludes a same-level Item */
  1244.     (APTR)&IText15,    /* Item render  (IntuiText or Image or NULL) */
  1245.     NULL,    /* Select render */
  1246.     NULL,    /* alternate command-key */
  1247.     NULL,    /* SubItem list */
  1248.     MENUNULL    /* filled in by Intuition for drag selections */
  1249. };
  1250.  
  1251. struct Menu __aligned Menu1 = {
  1252.     &Menu2,    /* next Menu structure */
  1253.     0,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  1254.     39,0,    /* Menu hit box width and height */
  1255.     MENUENABLED,    /* Menu flags */
  1256.     "File",    /* text of Menu name */
  1257.     &MenuItem12    /* MenuItem linked list pointer */
  1258. };
  1259.  
  1260. #define MenuList1 Menu1
  1261.  
  1262. struct NewWindow __aligned NewWindowStructure1 = {
  1263.     0,0,    /* window XY origin relative to TopLeft of screen */
  1264.     WIDTH,THEIGHT,    /* window width and height */
  1265.     0,TBLOCKPEN,    /* detail and block pens */
  1266.     MOUSEBUTTONS|MENUPICK|RAWKEY,    /* IDCMP flags */
  1267.     BACKDROP+BORDERLESS+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  1268.     NULL,    /* first gadget in gadget list */
  1269.     NULL,    /* custom CHECKMARK imagery */
  1270.     " ",    /* window title */
  1271.     NULL,    /* custom screen pointer */
  1272.     NULL,    /* custom bitmap */
  1273.     WIDTH,THEIGHT,    /* minimum width and height */
  1274.     0xffff,0xffff,    /* maximum width and height */
  1275.     CUSTOMSCREEN    /* destination screen type */
  1276. };
  1277.  
  1278. SHORT __far __aligned BorderVectors1[] = {
  1279.     0,0,
  1280.     81,0,
  1281.     81,38,
  1282.     0,38,
  1283.     0,0
  1284. };
  1285. struct Border __far __aligned Border1 = {
  1286.     -1,-1,    /* XY origin relative to container TopLeft */
  1287.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1288.     5,    /* number of XY vectors */
  1289.     BorderVectors1,    /* pointer to XY vectors */
  1290.     NULL    /* next border in list */
  1291. };
  1292.  
  1293. struct IntuiText __far __aligned IText16 = {
  1294.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1295.     31,15,    /* XY origin relative to container TopLeft */
  1296.     NULL,    /* font pointer or NULL for default */
  1297.     "OK",    /* pointer to text */
  1298.     NULL    /* next IntuiText structure */
  1299. };
  1300.  
  1301. struct Gadget __far __aligned Gadget1 = {
  1302.     NULL,    /* next gadget */
  1303.     155,233,    /* origin XY of hit box relative to window TopLeft */
  1304.     80,37,    /* hit box width and height */
  1305.     NULL,    /* gadget flags */
  1306.     RELVERIFY,    /* activation flags */
  1307.     BOOLGADGET,    /* gadget type flags */
  1308.     (APTR)&Border1,    /* gadget border or image to be rendered */
  1309.     NULL,    /* alternate imagery for selection */
  1310.     &IText16,    /* first IntuiText structure */
  1311.     NULL,    /* gadget mutual-exclude long word */
  1312.     NULL,    /* SpecialInfo structure */
  1313.     NULL,    /* user-definable data */
  1314.     NULL    /* pointer to user-definable data */
  1315. };
  1316.  
  1317. #define GadgetList2 Gadget1
  1318.  
  1319. struct IntuiText __far __aligned IText22 = {
  1320.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1321.     143,130,    /* XY origin relative to container TopLeft */
  1322.     NULL,    /* font pointer or NULL for default */
  1323.     "of Computers.",    /* pointer to text */
  1324.     NULL    /* next IntuiText structure */
  1325. };
  1326.  
  1327. struct IntuiText __far __aligned IText21 = {
  1328.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1329.     115,117,    /* XY origin relative to container TopLeft */
  1330.     NULL,    /* font pointer or NULL for default */
  1331.     "For the Amiga Family",    /* pointer to text */
  1332.     &IText22    /* next IntuiText structure */
  1333. };
  1334.  
  1335. struct IntuiText __far __aligned IText20 = {
  1336.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1337.     104,102,    /* XY origin relative to container TopLeft */
  1338.     NULL,    /* font pointer or NULL for default */
  1339.     "Chess Program Available",    /* pointer to text */
  1340.     &IText21    /* next IntuiText structure */
  1341. };
  1342.  
  1343. struct IntuiText __far __aligned IText19 = {
  1344.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1345.     108,87,    /* XY origin relative to container TopLeft */
  1346.     NULL,    /* font pointer or NULL for default */
  1347.     "The strongest Playing",    /* pointer to text */
  1348.     &IText20    /* next IntuiText structure */
  1349. };
  1350.  
  1351. struct IntuiText __far __aligned IText18 = {
  1352.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1353.     126,31,    /* XY origin relative to container TopLeft */
  1354.     NULL,    /* font pointer or NULL for default */
  1355.     "by Roger Uzun",    /* pointer to text */
  1356.     &IText19    /* next IntuiText structure */
  1357. };
  1358.  
  1359. struct IntuiText __far __aligned IText17 = {
  1360.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1361.     131,18,    /* XY origin relative to container TopLeft */
  1362.     NULL,    /* font pointer or NULL for default */
  1363.     VERSTRING,    /* pointer to text */
  1364.     &IText18    /* next IntuiText structure */
  1365. };
  1366.  
  1367. struct NewWindow __far __aligned NewWindowStructure2 = {
  1368.     125,30,    /* window XY origin relative to TopLeft of screen */
  1369.     390,290,    /* window width and height */
  1370.     0,TBLOCKPEN,    /* detail and block pens */
  1371.     VANILLAKEY|GADGETUP,    /* IDCMP flags */
  1372.     SIMPLE_REFRESH+NOCAREREFRESH+ACTIVATE,    /* other window flags */
  1373.     &Gadget1,    /* first gadget in gadget list */
  1374.     NULL,    /* custom CHECKMARK imagery */
  1375. #ifdef _M68040
  1376.     "UChess Pro",    /* window title */
  1377. #else
  1378. #ifndef TINYCHESS
  1379.     "UChess Jr.",    /* window title */
  1380. #else
  1381.     "UChess Tiny",    /* window title */
  1382. #endif
  1383. #endif
  1384.     NULL,    /* custom screen pointer */
  1385.     NULL,    /* custom bitmap */
  1386.     5,5,    /* minimum width and height */
  1387.     0xffff,0xffff,    /* maximum width and height */
  1388.     CUSTOMSCREEN    /* destination screen type */
  1389. };
  1390.  
  1391.  
  1392. SHORT __far __aligned aBorderVectors1[] = {
  1393.     0,0,
  1394.     77,0,
  1395.     77,25,
  1396.     0,25,
  1397.     0,0
  1398. };
  1399. struct Border __far __aligned aBorder1 = {
  1400.     -1,-1,    /* XY origin relative to container TopLeft */
  1401.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1402.     5,    /* number of XY vectors */
  1403.     aBorderVectors1,    /* pointer to XY vectors */
  1404.     NULL    /* next border in list */
  1405. };
  1406.  
  1407. struct IntuiText __far __aligned aIText1 = {
  1408.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1409.     16,8,    /* XY origin relative to container TopLeft */
  1410.     NULL,    /* font pointer or NULL for default */
  1411.     "KNIGHT",    /* pointer to text */
  1412.     NULL    /* next IntuiText structure */
  1413. };
  1414.  
  1415. struct Gadget __far __aligned aGadget4 = {
  1416.     NULL,    /* next gadget */
  1417.     55,124,    /* origin XY of hit box relative to window TopLeft */
  1418.     76,24,    /* hit box width and height */
  1419.     NULL,    /* gadget flags */
  1420.     RELVERIFY,    /* activation flags */
  1421.     BOOLGADGET,    /* gadget type flags */
  1422.     (APTR)&aBorder1,    /* gadget border or image to be rendered */
  1423.     NULL,    /* alternate imagery for selection */
  1424.     &aIText1,    /* first IntuiText structure */
  1425.     NULL,    /* gadget mutual-exclude long word */
  1426.     NULL,    /* SpecialInfo structure */
  1427.     NULL,    /* user-definable data */
  1428.     NULL    /* pointer to user-definable data */
  1429. };
  1430.  
  1431. SHORT __far __aligned aBorderVectors2[] = {
  1432.     0,0,
  1433.     77,0,
  1434.     77,25,
  1435.     0,25,
  1436.     0,0
  1437. };
  1438. struct Border __far __aligned aBorder2 = {
  1439.     -1,-1,    /* XY origin relative to container TopLeft */
  1440.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1441.     5,    /* number of XY vectors */
  1442.     aBorderVectors2,    /* pointer to XY vectors */
  1443.     NULL    /* next border in list */
  1444. };
  1445.  
  1446. struct IntuiText __far __aligned aIText2 = {
  1447.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1448.     15,8,    /* XY origin relative to container TopLeft */
  1449.     NULL,    /* font pointer or NULL for default */
  1450.     "BISHOP",    /* pointer to text */
  1451.     NULL    /* next IntuiText structure */
  1452. };
  1453.  
  1454. struct Gadget __far __aligned aGadget3 = {
  1455.     &aGadget4,    /* next gadget */
  1456.     55,92,    /* origin XY of hit box relative to window TopLeft */
  1457.     76,24,    /* hit box width and height */
  1458.     NULL,    /* gadget flags */
  1459.     RELVERIFY,    /* activation flags */
  1460.     BOOLGADGET,    /* gadget type flags */
  1461.     (APTR)&aBorder2,    /* gadget border or image to be rendered */
  1462.     NULL,    /* alternate imagery for selection */
  1463.     &aIText2,    /* first IntuiText structure */
  1464.     NULL,    /* gadget mutual-exclude long word */
  1465.     NULL,    /* SpecialInfo structure */
  1466.     NULL,    /* user-definable data */
  1467.     NULL    /* pointer to user-definable data */
  1468. };
  1469.  
  1470. SHORT __far __aligned aBorderVectors3[] = {
  1471.     0,0,
  1472.     77,0,
  1473.     77,25,
  1474.     0,25,
  1475.     0,0
  1476. };
  1477. struct Border __far __aligned aBorder3 = {
  1478.     -1,-1,    /* XY origin relative to container TopLeft */
  1479.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1480.     5,    /* number of XY vectors */
  1481.     aBorderVectors3,    /* pointer to XY vectors */
  1482.     NULL    /* next border in list */
  1483. };
  1484.  
  1485. struct IntuiText __far __aligned aIText3 = {
  1486.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1487.     19,8,    /* XY origin relative to container TopLeft */
  1488.     NULL,    /* font pointer or NULL for default */
  1489.     "ROOK",    /* pointer to text */
  1490.     NULL    /* next IntuiText structure */
  1491. };
  1492.  
  1493. struct Gadget __far __aligned aGadget2 = {
  1494.     &aGadget3,    /* next gadget */
  1495.     55,60,    /* origin XY of hit box relative to window TopLeft */
  1496.     76,24,    /* hit box width and height */
  1497.     NULL,    /* gadget flags */
  1498.     RELVERIFY,    /* activation flags */
  1499.     BOOLGADGET,    /* gadget type flags */
  1500.     (APTR)&aBorder3,    /* gadget border or image to be rendered */
  1501.     NULL,    /* alternate imagery for selection */
  1502.     &aIText3,    /* first IntuiText structure */
  1503.     NULL,    /* gadget mutual-exclude long word */
  1504.     NULL,    /* SpecialInfo structure */
  1505.     NULL,    /* user-definable data */
  1506.     NULL    /* pointer to user-definable data */
  1507. };
  1508.  
  1509. SHORT __far __aligned aBorderVectors4[] = {
  1510.     0,0,
  1511.     77,0,
  1512.     77,25,
  1513.     0,25,
  1514.     0,0
  1515. };
  1516. struct Border __far __aligned aBorder4 = {
  1517.     -1,-1,    /* XY origin relative to container TopLeft */
  1518.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1519.     5,    /* number of XY vectors */
  1520.     aBorderVectors4,    /* pointer to XY vectors */
  1521.     NULL    /* next border in list */
  1522. };
  1523.  
  1524. struct IntuiText __far __aligned aIText4 = {
  1525.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1526.     16,8,    /* XY origin relative to container TopLeft */
  1527.     NULL,    /* font pointer or NULL for default */
  1528.     "QUEEN",    /* pointer to text */
  1529.     NULL    /* next IntuiText structure */
  1530. };
  1531.  
  1532. struct Gadget __far __aligned aGadget1 = {
  1533.     &aGadget2,    /* next gadget */
  1534.     55,28,    /* origin XY of hit box relative to window TopLeft */
  1535.     76,24,    /* hit box width and height */
  1536.     NULL,    /* gadget flags */
  1537.     RELVERIFY,    /* activation flags */
  1538.     BOOLGADGET,    /* gadget type flags */
  1539.     (APTR)&aBorder4,    /* gadget border or image to be rendered */
  1540.     NULL,    /* alternate imagery for selection */
  1541.     &aIText4,    /* first IntuiText structure */
  1542.     NULL,    /* gadget mutual-exclude long word */
  1543.     NULL,    /* SpecialInfo structure */
  1544.     NULL,    /* user-definable data */
  1545.     NULL    /* pointer to user-definable data */
  1546. };
  1547.  
  1548.  
  1549. struct IntuiText __far __aligned aIText5 = {
  1550.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1551.     33,14,    /* XY origin relative to container TopLeft */
  1552.     &TOPAZ80,    /* font pointer or NULL for default */
  1553.     "Promote Pawn to",    /* pointer to text */
  1554.     NULL    /* next IntuiText structure */
  1555. };
  1556.  
  1557.  
  1558. struct NewWindow __aligned NewWindowStructure6 = {
  1559.     220,35,    /* window XY origin relative to TopLeft of screen */
  1560.     200,170,    /* window width and height */
  1561.     0,TBLOCKPEN,    /* detail and block pens */
  1562.     GADGETUP,    /* IDCMP flags */
  1563.     SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  1564.     &aGadget1,    /* first gadget in gadget list */
  1565.     NULL,    /* custom CHECKMARK imagery */
  1566.     "Promote Piece",    /* window title */
  1567.     NULL,    /* custom screen pointer */
  1568.     NULL,    /* custom bitmap */
  1569.     5,5,    /* minimum width and height */
  1570.     0xffff,0xffff,    /* maximum width and height */
  1571.     CUSTOMSCREEN    /* destination screen type */
  1572. };
  1573.  
  1574. #define MOVENOWMENUNUM 0x42
  1575. #define THINKMENUNUM 0x82
  1576. #define SHOWMENUNUM 0xa2
  1577. #define BOOKMENUNUM 0xc2
  1578. #define SUPERMENUNUM 0xe2
  1579. #define ADVANCEDMENUNUM 0x102
  1580. #define INTERMEDIATEMENUNUM 0x122
  1581. #define EASYMENUNUM 0x142
  1582.  
  1583.  
  1584. SHORT __far __aligned pBorderVectors1[] = {
  1585.     0,0,
  1586.     68,0,
  1587.     68,31,
  1588.     0,31,
  1589.     0,0
  1590. };
  1591. struct Border __far __aligned pBorder1 = {
  1592.     -1,-1,    /* XY origin relative to container TopLeft */
  1593.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1594.     5,    /* number of XY vectors */
  1595.     pBorderVectors1,    /* pointer to XY vectors */
  1596.     NULL    /* next border in list */
  1597. };
  1598.  
  1599. struct IntuiText __far __aligned pIText1 = {
  1600.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1601.     13,11,    /* XY origin relative to container TopLeft */
  1602.     &TOPAZ80,    /* font pointer or NULL for default */
  1603.     "DONE",    /* pointer to text */
  1604.     NULL    /* next IntuiText structure */
  1605. };
  1606.  
  1607. struct Gadget __far __aligned pGadget4 = {
  1608.     NULL,    /* next gadget */
  1609.     104,172,    /* origin XY of hit box relative to window TopLeft */
  1610.     67,30,    /* hit box width and height */
  1611.     NULL,    /* gadget flags */
  1612.     RELVERIFY,    /* activation flags */
  1613.     BOOLGADGET,    /* gadget type flags */
  1614.     (APTR)&pBorder1,    /* gadget border or image to be rendered */
  1615.     NULL,    /* alternate imagery for selection */
  1616.     &pIText1,    /* first IntuiText structure */
  1617.     NULL,    /* gadget mutual-exclude long word */
  1618.     NULL,    /* SpecialInfo structure */
  1619.     NULL,    /* user-definable data */
  1620.     NULL    /* pointer to user-definable data */
  1621. };
  1622.  
  1623. SHORT __far __aligned pBorderVectors2[] = {
  1624.     0,0,
  1625.     68,0,
  1626.     68,31,
  1627.     0,31,
  1628.     0,0
  1629. };
  1630. struct Border __far __aligned pBorder2 = {
  1631.     -1,-1,    /* XY origin relative to container TopLeft */
  1632.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1633.     5,    /* number of XY vectors */
  1634.     pBorderVectors2,    /* pointer to XY vectors */
  1635.     NULL    /* next border in list */
  1636. };
  1637.  
  1638. struct IntuiText __far __aligned pIText2 = {
  1639.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1640.     117,132,    /* was 13,11 XY origin relative to container TopLeft */
  1641.     &TOPAZ80,    /* font pointer or NULL for default */
  1642.     "WHITE",    /* pointer to text */
  1643.     NULL    /* next IntuiText structure */
  1644. };
  1645.  
  1646. struct IntuiText __far __aligned pIText2a = {
  1647.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1648.     117,132,    /* was 13,11 XY origin relative to container TopLeft */
  1649.     &TOPAZ80,    /* font pointer or NULL for default */
  1650.     "BLACK",    /* pointer to text */
  1651.     NULL    /* next IntuiText structure */
  1652. };
  1653.  
  1654. struct Gadget __far __aligned pGadget3 = {
  1655.     &pGadget4,    /* next gadget */
  1656.     104,121,    /* origin XY of hit box relative to window TopLeft */
  1657.     67,30,    /* hit box width and height */
  1658.     NULL,    /* gadget flags */
  1659.     RELVERIFY,    /* activation flags */
  1660.     BOOLGADGET,    /* gadget type flags */
  1661.     (APTR)&pBorder2,    /* gadget border or image to be rendered */
  1662.     NULL,    /* alternate imagery for selection */
  1663.     NULL,    /* first IntuiText structure */
  1664.     NULL,    /* gadget mutual-exclude long word */
  1665.     NULL,    /* SpecialInfo structure */
  1666.     NULL,    /* user-definable data */
  1667.     NULL    /* pointer to user-definable data */
  1668. };
  1669.  
  1670. SHORT __far __aligned pBorderVectors3[] = {
  1671.     0,0,
  1672.     68,0,
  1673.     68,31,
  1674.     0,31,
  1675.     0,0
  1676. };
  1677. struct Border __far __aligned pBorder3 = {
  1678.     -1,-1,    /* XY origin relative to container TopLeft */
  1679.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1680.     5,    /* number of XY vectors */
  1681.     pBorderVectors3,    /* pointer to XY vectors */
  1682.     NULL    /* next border in list */
  1683. };
  1684.  
  1685. struct IntuiText __far __aligned pIText3 = {
  1686.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1687.     0,12,    /* XY origin relative to container TopLeft */
  1688.     &TOPAZ80,    /* font pointer or NULL for default */
  1689.     "Clear BD",    /* pointer to text */
  1690.     NULL    /* next IntuiText structure */
  1691. };
  1692.  
  1693. struct Gadget __far __aligned pGadget2 = {
  1694.     &pGadget3,    /* next gadget */
  1695.     105,82,    /* origin XY of hit box relative to window TopLeft */
  1696.     67,30,    /* hit box width and height */
  1697.     NULL,    /* gadget flags */
  1698.     RELVERIFY,    /* activation flags */
  1699.     BOOLGADGET,    /* gadget type flags */
  1700.     (APTR)&pBorder3,    /* gadget border or image to be rendered */
  1701.     NULL,    /* alternate imagery for selection */
  1702.     &pIText3,    /* first IntuiText structure */
  1703.     NULL,    /* gadget mutual-exclude long word */
  1704.     NULL,    /* SpecialInfo structure */
  1705.     NULL,    /* user-definable data */
  1706.     NULL    /* pointer to user-definable data */
  1707. };
  1708.  
  1709. UBYTE __aligned pppSIBuff[4];
  1710. struct StringInfo __aligned pppSInfo = {
  1711.     pppSIBuff,    /* buffer where text will be edited */
  1712.     NULL,    /* optional undo buffer */
  1713.     0,    /* character position in buffer */
  1714.     4,    /* maximum number of characters to allow */
  1715.     0,    /* first displayed character buffer position */
  1716.     0,0,0,0,0,    /* Intuition initialized and maintained variables */
  1717.     0,    /* Rastport of gadget */
  1718.     0,    /* initial value for integer gadgets */
  1719.     NULL    /* alternate keymap (fill in if you set the flag) */
  1720. };
  1721.  
  1722. SHORT __far __aligned pBorderVectors4[] = {
  1723.     0,0,
  1724.     55,0,
  1725.     55,16, /* was 55,24 and 0, 24 */
  1726.     0,16,
  1727.     0,0
  1728. };
  1729. struct Border __far __aligned pBorder4 = {
  1730.     -1,-1,    /* XY origin relative to container TopLeft */
  1731.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1732.     5,    /* number of XY vectors */
  1733.     pBorderVectors4,    /* pointer to XY vectors */
  1734.     NULL    /* next border in list */
  1735. };
  1736.  
  1737. struct Gadget __far __aligned pGadget1 = {
  1738.     &pGadget2,    /* next gadget */
  1739.     180,57,    /* origin XY of hit box relative to window TopLeft */
  1740.     54,15,    /* was 54, 23 hit box width and height */
  1741.     NULL,    /* gadget flags */
  1742.     RELVERIFY,    /* activation flags */
  1743.     STRGADGET,    /* gadget type flags */
  1744.     (APTR)&pBorder4,    /* gadget border or image to be rendered */
  1745.     NULL,    /* alternate imagery for selection */
  1746.     NULL,    /* first IntuiText structure */
  1747.     NULL,    /* gadget mutual-exclude long word */
  1748.     (APTR)&pppSInfo,    /* SpecialInfo structure */
  1749.     NULL,    /* user-definable data */
  1750.     NULL    /* pointer to user-definable data */
  1751. };
  1752.  
  1753. struct IntuiText __far __aligned pIText8a = {
  1754.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1755.     32,44,    /* XY origin relative to container TopLeft */
  1756.     NULL,    /* font pointer or NULL for default */
  1757.     "use space to clr a square",    /* pointer to text */
  1758.     NULL    /* next IntuiText structure */
  1759. };
  1760.  
  1761. struct IntuiText __far __aligned pIText7 = {
  1762.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1763.     26,34,    /* XY origin relative to container TopLeft */
  1764.     NULL,    /* font pointer or NULL for default */
  1765.     "Bd is updated after edit session",    /* pointer to text */
  1766.     &pIText8a    /* next IntuiText structure */
  1767. };
  1768.  
  1769. struct IntuiText __far __aligned pIText6 = {
  1770.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1771.     68,62,    /* XY origin relative to container TopLeft */
  1772.     NULL,    /* font pointer or NULL for default */
  1773.     "Piece to add",    /* pointer to text */
  1774.     &pIText7    /* next IntuiText structure */
  1775. };
  1776.  
  1777. struct IntuiText __far __aligned pIText5 = {
  1778.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1779.     59,24,    /* XY origin relative to container TopLeft */
  1780.     NULL,    /* font pointer or NULL for default */
  1781.     "pa1 for pawn at a1, etc.",    /* pointer to text */
  1782.     &pIText6    /* next IntuiText structure */
  1783. };
  1784.  
  1785. struct IntuiText __far __aligned pIText4 = {
  1786.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1787.     63,14,    /* XY origin relative to container TopLeft */
  1788.     NULL,    /* font pointer or NULL for default */
  1789.     "Enter Pieces in format",    /* pointer to text */
  1790.     &pIText5    /* next IntuiText structure */
  1791. };
  1792.  
  1793. struct NewWindow __far __aligned pNewWindowStructure1 = {
  1794.     170,30,    /* window XY origin relative to TopLeft of screen */
  1795.     300,220,    /* window width and height */
  1796.     0,TBLOCKPEN,    /* detail and block pens */
  1797.     GADGETUP+CLOSEWINDOW,    /* IDCMP flags */
  1798.     WINDOWCLOSE+SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  1799.     &pGadget1,    /* first gadget in gadget list */
  1800.     NULL,    /* custom CHECKMARK imagery */
  1801.     "Edit Board",    /* window title */
  1802.     NULL,    /* custom screen pointer */
  1803.     NULL,    /* custom bitmap */
  1804.     5,5,    /* minimum width and height */
  1805.     0xffff,0xffff,    /* maximum width and height */
  1806.     CUSTOMSCREEN    /* destination screen type */
  1807. };
  1808.  
  1809. void mysprintf(char *,char *,int);
  1810. void mysprintf2(char *,char *,int,int);
  1811.  
  1812.  
  1813. void
  1814. SetTimeControl2 (color)
  1815. int color;
  1816. {
  1817.  int tmp;
  1818.  int other;
  1819.  
  1820.   other = color ^ 1;
  1821.   if (TCflag)
  1822.     {
  1823.       TimeControl.moves[color] = TCmoves;
  1824.       TimeControl.clock[color] += (6000L * TCminutes + TCseconds * 100);
  1825.       tmp = (TCminutes*60+TCseconds)/TCmoves;
  1826.       if (color == computer)
  1827.        {
  1828.       SecsPerMove = tmp;
  1829.       if (tmp < 10)
  1830.        {
  1831.         GlobalTgtDepth = 2;
  1832.        }
  1833.       else if (tmp < 180)
  1834.        {
  1835.         GlobalTgtDepth = 3;
  1836.        }
  1837.       else
  1838.        GlobalTgtDepth = 4;
  1839.       }
  1840.       TimeControl.moves[other] = TCmoves;
  1841.       TimeControl.clock[other] += (6000L * TCminutes + TCseconds * 100);
  1842.       tmp = (TCminutes*60+TCseconds)/TCmoves;
  1843.       if (other == computer)
  1844.        {
  1845.       SecsPerMove = tmp;
  1846.       if (tmp < 10)
  1847.        {
  1848.         GlobalTgtDepth = 2;
  1849.        }
  1850.       else if (tmp < 180)
  1851.        {
  1852.         GlobalTgtDepth = 3;
  1853.        }
  1854.       else
  1855.        GlobalTgtDepth = 4;
  1856.       }
  1857.     }
  1858.   else
  1859.     {
  1860.       TimeControl.moves[color] = 0;
  1861.       TimeControl.clock[color] = 0;
  1862.       TimeControl.moves[other] = 0;
  1863.       TimeControl.clock[other] = 0;
  1864.     }
  1865.   flag.onemove = (TCmoves == 1);
  1866.   et = 0;
  1867.   ElapsedTime (1);
  1868. }
  1869.  
  1870. void DoEasy()
  1871. {
  1872.  
  1873.     PlayMode = 0;
  1874.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  1875.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  1876.     LoadBobImage(BLANKDATA);
  1877.     if (SYSTEM_BOBS)
  1878.      {
  1879.       SortGList(rpG);
  1880.       DrawGList(rpG,vP);
  1881.       MakeVPort(GfxBase->ActiView,vP);
  1882.       MrgCop(GfxBase->ActiView);
  1883.       WaitTOF();
  1884.       RethinkDisplay();
  1885.      }
  1886.     NewGame();
  1887. }
  1888.  
  1889. void DoAdvanced()
  1890. {
  1891.  
  1892.     PlayMode = 2;
  1893.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  1894.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  1895.     LoadBobImage(BLANKDATA);
  1896.     if (SYSTEM_BOBS)
  1897.      {
  1898.       SortGList(rpG);
  1899.       DrawGList(rpG,vP);
  1900.      }
  1901.     MakeVPort(GfxBase->ActiView,vP);
  1902.     MrgCop(GfxBase->ActiView);
  1903.     WaitTOF();
  1904.     RethinkDisplay();
  1905.     NewGame();
  1906. }
  1907.  
  1908. void DoIntermediate()
  1909. {
  1910.  
  1911.     PlayMode = 1;
  1912.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  1913.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  1914.     LoadBobImage(BLANKDATA);
  1915.     if (SYSTEM_BOBS)
  1916.      {
  1917.       SortGList(rpG);
  1918.       DrawGList(rpG,vP);
  1919.      }
  1920.     MakeVPort(GfxBase->ActiView,vP);
  1921.     MrgCop(GfxBase->ActiView);
  1922.     WaitTOF();
  1923.     RethinkDisplay();
  1924.     NewGame();
  1925. }
  1926.  
  1927. void mysprintf(ostr,fstr,num)
  1928. char *ostr,*fstr;
  1929. int num;
  1930. { // formats string "%d: xxx"
  1931.  
  1932.  int index;
  1933.  int thou,hun,ten,one,rem;
  1934.  
  1935.  
  1936.  if (num < 0) 
  1937.   {
  1938.    num = -num;
  1939.    index = 1;
  1940.    strcpy(ostr,"-");
  1941.   }
  1942.  else
  1943.   {
  1944.    index = 0;
  1945.    ostr[0] = 0;
  1946.   }
  1947.  thou = num / 1000;
  1948.  rem = num-(num / 1000)*1000;
  1949.  hun = (rem / 100);
  1950.  rem = rem-(hun * 100);
  1951.  ten = rem / 10;
  1952.  rem = rem-(ten * 10);
  1953.  one = rem;
  1954.  if (thou)
  1955.   {
  1956.    ostr[index++] = thou+'0';
  1957.   }
  1958.  if ((hun)||(thou))
  1959.   {
  1960.    ostr[index++] = hun+'0';
  1961.   }
  1962.  if ((ten)||(hun)||(thou))
  1963.   {
  1964.    ostr[index++] = ten+'0';
  1965.   }
  1966.  ostr[index++] = one+'0';
  1967.  ostr[index] = 0;
  1968.  strcat(ostr,&fstr[2]);
  1969. }
  1970.  
  1971. void mysprintf2(ostr,fstr,num,num2)
  1972. char *ostr,*fstr;
  1973. int num,num2;
  1974. { // formats string "%d: xxx"
  1975.  
  1976.  int index;
  1977.  int thou,hun,ten,one,rem;
  1978.  
  1979.  
  1980.  if (num < 0) 
  1981.   {
  1982.    num = -num;
  1983.    index = 1;
  1984.    strcpy(ostr,"-");
  1985.   }
  1986.  else
  1987.   {
  1988.    index = 0;
  1989.    ostr[0] = 0;
  1990.   }
  1991.  thou = num / 1000;
  1992.  rem = num-(num / 1000)*1000;
  1993.  hun = (rem / 100);
  1994.  rem = rem-(hun * 100);
  1995.  ten = rem / 10;
  1996.  rem = rem-(ten * 10);
  1997.  one = rem;
  1998.  if (thou)
  1999.   {
  2000.    ostr[index++] = thou+'0';
  2001.   }
  2002.  if ((hun)||(thou))
  2003.   {
  2004.    ostr[index++] = hun+'0';
  2005.   }
  2006.  if ((ten)||(hun)||(thou))
  2007.   {
  2008.    ostr[index++] = ten+'0';
  2009.   }
  2010.  ostr[index++] = one+'0';
  2011.  ostr[index++] = ':';
  2012.  
  2013.  ten = num2 / 10;
  2014.  one = num2 % 10;
  2015.  ostr[index++] = ten+'0';
  2016.  ostr[index++] = one+'0';
  2017.  ostr[index] = 0;
  2018.  strcat(ostr,&fstr[7]);
  2019. }
  2020.  
  2021. void
  2022. gsrand (unsigned int seed);
  2023.  
  2024.  
  2025. void calc_pgm_rating()
  2026. {
  2027.  /* 34 secs on an RS/6000 which is about 2338, so to rate itself
  2028.     rating = 2338 - 75*(log2(time) - log2(34)) */
  2029.  
  2030.  int st;
  2031.  unsigned int secs;
  2032.  int rating;
  2033.  int tmpbk,Old,oldtc;
  2034.  int OldPM;
  2035.  char tstr[32],tstr2[32];
  2036.  
  2037.  OldPM = PlayMode;
  2038.  PlayMode = 2;
  2039.  tmpbk = Book;
  2040.  oldtc = TCflag;
  2041.  Old = MaxSearchDepth;
  2042.  NewGame ();
  2043.  UpdateDisplay (0, 0, 1, 0);
  2044.  MaxSearchDepth = 6;
  2045.  Book = 0;
  2046.  TCflag = 0;
  2047.  computer = computer ^ 1;
  2048.  opponent = opponent ^ 1;
  2049.  xwndw = (computer == white) ? WXWNDW : BXWNDW;
  2050.  flag.force = false;
  2051.  Sdepth = 0;
  2052.  ShowMessage("Calculating.");
  2053.  ShowMessage("Please wait.");
  2054.  SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  2055.  st = time(0L);
  2056.  SelectMove (computer, 1);
  2057.  secs = st = time(0L) - st;
  2058.  ClearPointer(wG);
  2059.  if (st<4)
  2060.   st = 4;
  2061.  st = (st - 2)/6;
  2062.  if (st > 200)
  2063.   {
  2064.    strcpy(tstr,"too slow Cannot rate");
  2065.   }
  2066.  else
  2067.   {
  2068.    if (st < 4)
  2069.     st = 4;
  2070. #ifdef PL_60
  2071.    rating = 2350 - (((75*log_e[st]) - (75*LOGE_34))/LN2);
  2072. #else /* patch level 61 */
  2073.    rating = 2350 - (((75*log_e[st]) - (75*LOGE_16))/LN2);
  2074. #endif
  2075. #ifndef _M68040 /* small mem model */
  2076. #ifdef TINYCHESS
  2077.    rating -= 41;
  2078. #else
  2079.    rating -= 21;
  2080. #endif
  2081. #endif
  2082.    rating -= 40;
  2083.    sprintf(tstr,"USCF %04d",rating);
  2084.   }
  2085.  Book = tmpbk;
  2086.  MaxSearchDepth = Old;
  2087.  TCflag = oldtc;
  2088.  PlayMode = OldPM;
  2089.  NewGame ();
  2090.  UpdateDisplay (0, 0, 1, 0);
  2091.  sprintf(tstr2," %d secs",secs);
  2092.  ShowMessage(tstr2);
  2093.  ShowMessage(tstr);
  2094. }
  2095.  
  2096. int DoResign()
  2097. {
  2098.  struct EasyStruct __aligned resignES = {
  2099.     sizeof (struct EasyStruct),
  2100.     0,
  2101.     "Resignation Alert",
  2102.     "Accept UChess's Resignation",
  2103.     "Yes|No",
  2104.   };
  2105.  
  2106.  ULONG __aligned iflags=0L;
  2107.  UBYTE    __aligned volname[4]={0,0,0,0};
  2108.  
  2109.  Delay(30L);
  2110.  DisplayBeep(0L);
  2111.  ResignOffered = -1;
  2112. /* return 0 if no resign accepted, yes if accepted */
  2113.  return(EasyRequest( wG, &resignES, &iflags, volname ));
  2114. }
  2115.  
  2116.  
  2117. void GetEditText(s,color)
  2118. char *s;
  2119. int *color;
  2120. { /* gets the edit string from the user */
  2121.   /* returns # for clr bd, c for change colors and pa1 to put a pawn at a1*/
  2122.   /* YOU MUST RETURN THE STRING IN ALL LOWER CASE! */
  2123.  
  2124.   int dun;
  2125.   long code,class;
  2126.   int i;
  2127.   APTR object;
  2128.   struct IntuiMessage *message;
  2129.  
  2130.   dun = 0;
  2131.   s[0] = 0;
  2132.   pppSIBuff[0] = '\0';
  2133.   ActivateGadget(&pGadget1,wGEdit,NULL);
  2134.   do {
  2135.   WaitPort(wGEdit->UserPort);
  2136.   while(message = (struct IntuiMessage *)GetMsg(wGEdit->UserPort))
  2137.   {
  2138.    code = message->Code;
  2139.    object = message->IAddress;
  2140.    class = message->Class;
  2141.    ReplyMsg((struct Message *)message);
  2142.    if (class == CLOSEWINDOW)
  2143.     {
  2144.      strcpy(s,".");
  2145.      dun = 1;
  2146.     }
  2147.    else if (class == GADGETUP)
  2148.     { /* text */
  2149.      if (object == (APTR)&pGadget1)
  2150.       {
  2151.        if (pppSIBuff[0])
  2152.         {
  2153.          dun = 1;
  2154.          strcpy(s,pppSIBuff);
  2155.          for(i=0;i<4;i++)
  2156.           s[i] = tolower(s[i]);
  2157.         }
  2158.       }
  2159.      else if (object == (APTR)&pGadget2)
  2160.       {
  2161.        dun = 1;
  2162.        strcpy(s,"#");
  2163.       }
  2164.      else if (object == (APTR)&pGadget3)
  2165.       { /* white/black */
  2166.        if (*color == white)
  2167.         *color = black;
  2168.        else
  2169.         *color = white;
  2170.        SetDrMd(wGEdit->RPort,JAM1);
  2171.        SetAPen(wGEdit->RPort,0L);
  2172.        RectFill(wGEdit->RPort,107,124,167,145);
  2173.        if (*color == white)
  2174.         PrintIText(wGEdit->RPort,&pIText2,0L,0L); /* white label */
  2175.        else
  2176.         PrintIText(wGEdit->RPort,&pIText2a,0L,0L); /* white label */
  2177.       }
  2178.      else if (object == (APTR)&pGadget4)
  2179.       { /* done */
  2180.        strcpy(s,".");
  2181.        dun = 1;
  2182.       }
  2183.     }
  2184.   }
  2185.  } while (!dun);
  2186.  DisplayBeep(0L);
  2187. }
  2188.  
  2189. void CloseAmigaEditWindow()
  2190. {
  2191.  struct IntuiMessage *message;
  2192.  
  2193.   while(message = (struct IntuiMessage *)GetMsg(wGEdit->UserPort))
  2194.   {
  2195.    ReplyMsg((struct Message *)message);
  2196.   }
  2197.  CloseWindow(wGEdit);
  2198. // if (DEPTH >= 6)
  2199. //  {
  2200. //   SetRGB32(vP,1,tmppal[0],tmppal[1],tmppal[2]);
  2201. //  }
  2202. // else
  2203. //  {
  2204. //   SetRGB4(vP,1,((tmppal[0]>>8)&0xf),((tmppal[0]>>4)&0xf),((tmppal[0])&0xf));
  2205. //  }
  2206. }
  2207.  
  2208.  
  2209. int OpenAmigaEditWindow() /* opens a window for edit board */
  2210.  {
  2211.   if (!(wGEdit = OpenWindow(&pNewWindowStructure1)))
  2212.    {
  2213.     DisplayBeep(0L);
  2214.     return(0);
  2215.    }
  2216. // if (DEPTH >= 6)
  2217. //  {
  2218. //   tmppal[0] = BigColorPalette[4];
  2219. //   tmppal[1] = BigColorPalette[5];
  2220. //   tmppal[2] = BigColorPalette[6];
  2221. //   SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  2222. //  }
  2223. // else
  2224.  // {
  2225.  //  tmppal[0] = myPalette[1];
  2226. //   SetRGB4(vP,1,0xa,0xa,0xa);
  2227. //  }
  2228.   pppSIBuff[0] = 0;
  2229.   pppSIBuff[3] = 0;
  2230.   PrintIText(wGEdit->RPort,&pIText4,0L,0L);
  2231.   PrintIText(wGEdit->RPort,&pIText2,0L,0L); /* white label */
  2232.   return(1);
  2233.  }
  2234.  
  2235.  
  2236. void EnableMoveNow()
  2237. {
  2238.  if (MenuStripSet)
  2239.   {
  2240.    MoveNowOK = 1;
  2241.    OnMenu(wG,MOVENOWMENUNUM); 
  2242.   }
  2243. }
  2244.  
  2245. void DisableMoveNow()
  2246. {
  2247.  if (MenuStripSet)
  2248.   {
  2249.    MoveNowOK = 0;
  2250.    OffMenu(wG,MOVENOWMENUNUM); 
  2251.   }
  2252. }
  2253.  
  2254. int GetFileName(char *s)
  2255. {
  2256.  int tmp;
  2257.  struct FileRequester *myFileReq;
  2258.  struct  TagItem  Tags[2] = {
  2259.  {ASLFR_Window,0L},
  2260.  {0,0}
  2261.  };
  2262.  
  2263.  Tags[0].ti_Data = (ULONG)wG;
  2264.  myFileReq = AllocAslRequest(ASL_FileRequest,Tags);
  2265.  if (myFileReq)
  2266.   {
  2267.    tmp = AslRequest(myFileReq,Tags);
  2268.    if (!tmp)
  2269.     {
  2270.      FreeAslRequest(myFileReq);
  2271.      return(0);
  2272.     }
  2273.    strcpy(s,myFileReq->fr_Drawer);
  2274.    if (s[0])
  2275.     {
  2276.      if ((s[strlen(s)-1] != ':')&&(s[strlen(s)-1] != '/'))
  2277.       {
  2278.        strcat(s,"/");
  2279.       }
  2280.     }
  2281.    strcat(s,myFileReq->fr_File);
  2282.    FreeAslRequest(myFileReq);
  2283.    return(0xff);
  2284.   }
  2285.  else
  2286.   return(0);
  2287. }
  2288.  
  2289. int GetScreenMode()
  2290. {
  2291.  int tmp;
  2292.  struct ScreenModeRequester *myScreenReq;
  2293.  struct TagItem  Tags[4] = {
  2294.  {ASLSM_InitialDisplayID,HIRES|LACE|DEFAULT_MONITOR_ID},
  2295.  {ASLSM_InitialAutoScroll,FALSE},
  2296.  {0,0}
  2297.  };
  2298.  
  2299.  myScreenReq = AllocAslRequest(ASL_ScreenModeRequest,0L);
  2300.  if (myScreenReq)
  2301.   {
  2302.    tmp = AslRequest(myScreenReq,Tags);
  2303.    if (!tmp)
  2304.     {
  2305.      FreeAslRequest(myScreenReq);
  2306.      return(0);
  2307.     }
  2308.    RTG_ModeID = myScreenReq->sm_DisplayID;
  2309.    FreeAslRequest(myScreenReq);
  2310.    return(0xff);
  2311.   }
  2312.  else
  2313.   return(0);
  2314. }
  2315.  
  2316. void
  2317. UpdateClocks (void)
  2318. {
  2319.   char tempstr[16];
  2320.   long ycoord;
  2321.   INTSIZE ref_min,ref_sec;
  2322.   ULONG max_time;
  2323.   INTSIZE m, s;
  2324.   int score_diff;
  2325.  
  2326.   m = (INTSIZE) (et / 6000);
  2327.   s = (INTSIZE) (et - 6000 * (long) m) / 100;
  2328.   if (TCflag)
  2329.     {
  2330.       m = (INTSIZE) ((TimeControl.clock[player] - et) / 6000);
  2331.       s = (INTSIZE) ((TimeControl.clock[player] - et - 6000 * (long) m) / 100);
  2332.     }
  2333.   if (m < 0)
  2334.     m = 0;
  2335.   if (s < 0)
  2336.     s = 0;
  2337.   if (player == computer)
  2338.    {
  2339.     ref_min = cmptr_min;
  2340.     ref_sec = cmptr_sec;
  2341.     ycoord = TIMEYCOORD1;
  2342.    }
  2343.   else
  2344.    {
  2345.     ref_min = hum_min;
  2346.     ref_sec = hum_sec;
  2347.     ycoord = TIMEYCOORD2;
  2348.    }
  2349.   if ((ref_min != m)||(ref_sec != s))
  2350.    {
  2351.     mysprintf2(tempstr,"%d:%02d     ",m,s);
  2352.     ObtainSemaphore(&mySemaphore);
  2353.     Move(rpG,540,ycoord);
  2354.     mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  2355.     RectFill(rpG,540,ycoord-6,621,ycoord+5);
  2356.     mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  2357.     Move(rpG,540,ycoord);
  2358.     Text(rpG,tempstr,strlen(tempstr));
  2359.     ReleaseSemaphore(&mySemaphore);
  2360.     if (player == computer)
  2361.      {
  2362.       score_diff = global_tmp_score - previous_score;
  2363.       cmptr_min = m;
  2364.       cmptr_sec = s;
  2365.       if (TCflag)
  2366.        {
  2367.         max_time = s + m*60;
  2368.         if ((TimeControl.moves[computer] < ((TCmoves/2)-2))&&(Sdepth > GlobalTgtDepth)&&
  2369.             (score_diff >= -55)&&(ResponseTime < 9999998)&&
  2370.             (max_time<(((TimeControl.moves[computer]-1)*SecsPerMove)>>1)))
  2371.          {//have little time available on 2nd half of game
  2372.           flag.back = true;
  2373.          }
  2374.         if ((!m)&&(s <= 1)&&(Sdepth > MINDEPTH))
  2375.          {
  2376.           flag.back = true;
  2377.          }
  2378.         if ((Sdepth > MINDEPTH)&&(!m)&&
  2379.             (s<((TimeControl.moves[player]-1)*5)))
  2380.          { // less than 1 min left on clock, less than 5 secs/move!
  2381.           flag.back = true;
  2382.          }
  2383.       }
  2384. //printf("prev score = %d  global_tmp_score = %d\n",previous_score,global_tmp_score);
  2385. //printf("score_diff = %d  Sdepth = %d GlobalTgtDepth = %d\n",score_diff,Sdepth,GlobalTgtDepth);
  2386.       if (((score_diff > -16))&&(Sdepth > GlobalTgtDepth)
  2387.           &&(OrigResponse > 2500)&&(global_tmp_score > -55))
  2388.        { // more than 25 secs/move and am not losing by too much
  2389.         ycoord = OrigResponse >> 1;
  2390.         if (ycoord > 3101)
  2391.          ycoord = 3101;
  2392.         max_time = OrigResponse + ycoord; // 1.5Xorig OR orig + 31 whichver is smaller
  2393. //printf("max time = %lu et = %lu\n",max_time,et);
  2394.        }
  2395.       else if (Sdepth > (GlobalTgtDepth))
  2396.        max_time = (OrigResponse<<1) + ExtraTime + 101;
  2397.       else
  2398.        max_time = ((OrigResponse<<1) + ExtraTime + OrigResponse);
  2399.       if ((TCflag) && (!trying_again) && (ResponseTime < 9999998) && (Sdepth > MINDEPTH)
  2400.           && ((et) >= max_time))
  2401.        {
  2402. //printf("Considering the move!\n");
  2403.         if (score_diff >= -75)
  2404.           {
  2405.            flag.back = true;
  2406.           }
  2407.        } 
  2408.      }
  2409.     else // human player
  2410.      {
  2411.       hum_min = m;
  2412.       hum_sec = s;
  2413.      }
  2414.    } // 1 sec or more has elapsed
  2415. }
  2416.  
  2417.  
  2418. char DisplayPromoteRequestor(void);
  2419.  
  2420. char DisplayPromoteRequestor()
  2421. {
  2422. // ULONG tmp[4];
  2423.  int dun;
  2424.  struct IntuiMessage __aligned *message;
  2425.  struct Window __aligned *wG3;
  2426.  UWORD __aligned code;
  2427.  ULONG __aligned class;
  2428.  APTR object;
  2429.  char retchar='q';
  2430.  
  2431. // if (DEPTH >= 6)
  2432. //  {
  2433. //   tmp[0] = BigColorPalette[4];
  2434. //   tmp[1] = BigColorPalette[5];
  2435. //   tmp[2] = BigColorPalette[6];
  2436. //   SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  2437. // }
  2438. // else
  2439. //  {
  2440. //   tmp[0] = myPalette[1];
  2441. //   SetRGB4(vP,1,0xa,0xa,0xa);
  2442. //  }
  2443.  if (!(wG3 = OpenWindow(&NewWindowStructure6)))
  2444.  {
  2445.   DisplayBeep(0L);
  2446.   return('q');
  2447.  }
  2448.  PrintIText(wG3->RPort,&aIText5,0L,0L);
  2449.  dun = 0;
  2450.  do {
  2451.  WaitPort(wG3->UserPort);
  2452.  while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2453.   {
  2454.    code = message->Code;
  2455.    object = message->IAddress;
  2456.    class = message->Class;
  2457.    ReplyMsg((struct Message *)message);
  2458.    dun = 1;
  2459.    if (object == (APTR)&aGadget1)
  2460.       {
  2461.        retchar = 'q';
  2462.       }
  2463.     else if (object == (APTR)&aGadget2)
  2464.       {
  2465.        retchar = 'r';
  2466.       }
  2467.     else if (object == (APTR)&aGadget3)
  2468.       {
  2469.        retchar = 'b';
  2470.       }
  2471.     else if (object == (APTR)&aGadget4)
  2472.       {
  2473.        retchar = 'n';
  2474.       }
  2475.   }
  2476.  } while (!dun);
  2477.  CloseWindow(wG3);
  2478. // if (DEPTH >= 6)
  2479. //  {
  2480. //   SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
  2481. //  }
  2482. // else
  2483.  // {
  2484.  //  SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
  2485. //  }
  2486.  return(retchar);
  2487. }
  2488.  
  2489. void tFreeBitMap(struct BitMap *);
  2490. void sFreeBitMap(struct BitMap *);
  2491. struct BitMap *tAllocBitMap(int,int,int,int,struct BitMap *);
  2492. struct BitMap *sAllocBitMap(int,int,int,int,struct BitMap *);
  2493.  
  2494. struct BitMap *tAllocBitMap(wid,ht,depth,flags,friend)
  2495. int wid,ht,depth,flags;
  2496. struct BitMap *friend;
  2497. {
  2498.  int i;
  2499.  unsigned long tt;
  2500.  LONG image_data;
  2501.  ULONG planes;
  2502.  struct BitMap *tmp;
  2503.  
  2504.  if (gfxversion < 39)
  2505.   {
  2506.    planes = RASSIZE(wid,ht);
  2507.    if (!(tmp = AllocMem(sizeof (struct BitMap),MEMF_CLEAR)))
  2508.     {
  2509.      return(0);
  2510.     }
  2511.    InitBitMap(tmp,depth,wid,ht);
  2512.    tt = planes*depth;
  2513.    if (!(tmp->Planes[0] = AllocMem(tt,MEMF_CHIP|MEMF_CLEAR)))
  2514.     {
  2515.      FreeMem(tmp,sizeof(struct BitMap));
  2516.      return(0);
  2517.     }
  2518.    image_data = (LONG)tmp->Planes[0];
  2519.    for(i=1;i<depth;i++)
  2520.     {
  2521.      tmp->Planes[i] = (PLANEPTR) (image_data + i * planes);
  2522.     }
  2523.   }
  2524.  else
  2525.   {
  2526.    tmp = AllocBitMap(wid,ht,depth,flags,friend);
  2527.   }
  2528.  return(tmp);
  2529. }
  2530.  
  2531. struct BitMap *sAllocBitMap(wid,ht,depth,flags,friend)
  2532. int wid,ht,depth,flags;
  2533. struct BitMap *friend;
  2534. {
  2535.  int i;
  2536.  unsigned long tt;
  2537.  ULONG image_data;
  2538.  ULONG planes;
  2539.  struct BitMap *tmp;
  2540.  
  2541.  
  2542.  if (!(tmp = AllocMem(sizeof (struct BitMap),MEMF_CLEAR)))
  2543.   {
  2544.    return(0);
  2545.   }
  2546.  InitBitMap(tmp,8,640,480);
  2547.  planes = RASSIZE(640,480);
  2548.  tmp->BytesPerRow = 640;
  2549.  tmp->Flags = 0x0;
  2550.  tmp->Rows = 480;
  2551.  tmp->Depth = 8;
  2552.  tmp->pad = 32860;
  2553.  tt = planes*8;
  2554.  if (!(tmp->Planes[0] = AllocMem(tt,MEMF_CHIP|MEMF_CLEAR)))
  2555.   {
  2556.    FreeMem(tmp,sizeof(struct BitMap));
  2557.    return(0);
  2558.   }
  2559.  image_data = (ULONG)tmp->Planes[0];
  2560.  planes = 0x50;
  2561.  for(i=1;i<depth;i++)
  2562.   {
  2563.    tmp->Planes[i] = (PLANEPTR) (image_data + i * planes);
  2564.   }
  2565.  return(tmp);
  2566. }
  2567.  
  2568. void tFreeBitMap(bmap)
  2569. struct BitMap *bmap;
  2570. {
  2571.  ULONG numbytes;
  2572.  
  2573.  if (gfxversion < 39)
  2574.   {
  2575.    numbytes = bmap->Rows*bmap->BytesPerRow*bmap->Depth;
  2576.    FreeMem(bmap->Planes[0],numbytes);
  2577.    FreeMem(bmap,sizeof(struct BitMap));
  2578.   }
  2579.  else
  2580.   {
  2581.    FreeBitMap(bmap);
  2582.   }
  2583. }
  2584.  
  2585. void sFreeBitMap(bmap)
  2586. struct BitMap *bmap;
  2587. {
  2588.  ULONG numbytes,planes;
  2589.  
  2590.   planes = RASSIZE(640,480);
  2591.   numbytes = planes*8;
  2592.   FreeMem(bmap->Planes[0],numbytes);
  2593.   FreeMem(bmap,sizeof(struct BitMap));
  2594. }
  2595.  
  2596.  
  2597. int HandleEvent(object)
  2598. APTR object;
  2599. {
  2600.  int tmpdone=0;
  2601.  UWORD nextcode;
  2602.  struct MenuItem *myMenuItem;
  2603.  
  2604.  do {
  2605.   if (!RealThink)
  2606.    {
  2607.     if (object == (APTR)&MenuItem15) { DoQuit();return(1); }
  2608.     if (object == (APTR)&MenuItem1) { DoHint(); }
  2609.     if (object == (APTR)&MenuItem12) { DoAbout(); }
  2610.     //if (object == (APTR)&MenuItem6) { }
  2611.     if (object == (APTR)&MenuItem13) { LoadAGame(); }
  2612.     if (object == (APTR)&MenuItem14) { SaveAGame(); }
  2613.     if (object == (APTR)&MenuItem14a) { ListAGame();  }
  2614.     if (object == (APTR)&MenuItem9) { Go2D(); }
  2615.     if (object == (APTR)&MenuItem10) { EditBoard(); }
  2616.     if (object == (APTR)&MenuItem11) { DoReverse(); }
  2617.     if (object == (APTR)&MenuItem4) { DoSwap();  }
  2618.     if (object == (APTR)&MenuItem5) { DoAutoPlay(); }
  2619.     if (object == (APTR)&MenuItem7) { TakeBack();  }
  2620.     if (object == (APTR)&MenuItem8) { DoThinking();  }
  2621.     if (object == (APTR)&MenuItem8a) { DoShwThnk();  }
  2622.     if (object == (APTR)&MenuItem8aa) { DoSuper(); }
  2623.     if (object == (APTR)&MenuItem8ab) { DoBookToggle(); }
  2624.     if (object == (APTR)&MenuItem8ee) {strcpy(OpEntryStr,"advan");tmpdone = 1;}
  2625.     if (object == (APTR)&MenuItem8dd) {strcpy(OpEntryStr,"interm");tmpdone = 1;}
  2626.     if (object == (APTR)&MenuItem8cc) {strcpy(OpEntryStr,"easy");tmpdone = 1;}
  2627.     if (object == (APTR)&MenuItem2) { DoTest();  }
  2628.     if (object == (APTR)&MenuItem3) { SetTime(); }
  2629.     if (object == (APTR)&MenuItem3x) { strcpy(OpEntryStr,"calc");tmpdone = 1;}
  2630.     if (object == (APTR)&MenuItem3r) { ChangeSearchDepth();}
  2631.     if (object == (APTR)&MenuItem28) 
  2632.      {
  2633. #ifndef OLDNEW
  2634.       tmpdone = 1;
  2635.       strcpy(OpEntryStr,"new");
  2636. #else
  2637.       BobVSprite->X = WIDTH-1-BOBWIDTH;
  2638.       BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2639.       LoadBobImage(BLANKDATA);
  2640.       if (SYSTEM_BOBS)
  2641.        {
  2642.         SortGList(rpG);
  2643.         DrawGList(rpG,vP);
  2644.        }
  2645.       MakeVPort(GfxBase->ActiView,vP);
  2646.       MrgCop(GfxBase->ActiView);
  2647.       WaitTOF();
  2648.       RethinkDisplay();
  2649.       NewGame();
  2650. #endif
  2651.      }
  2652.    } // !RealThink
  2653.   else
  2654.    { // realthink
  2655.     if (object == (APTR)&MenuItem15) {MoveNow();while (RealThink) Delay(20L);DoQuit();return(1);}
  2656.     if (object == (APTR)&MenuItem6) { MoveNow();  }
  2657.     if (object == (APTR)&MenuItem8ab) { DoBookToggle(); }
  2658.     if (object == (APTR)&MenuItem8) { DoThinking();  }
  2659.     if (object == (APTR)&MenuItem8aa) { MoveNow();while (RealThink) Delay(20L);DoSuper(); }
  2660.     if (object == (APTR)&MenuItem8a) { DoShwThnk();  }
  2661.     if (object == (APTR)&MenuItem8ee) {MoveNow();while (RealThink) Delay(20L);strcpy(OpEntryStr,"advan");tmpdone = 1;}
  2662.     if (object == (APTR)&MenuItem8dd) {MoveNow();while (RealThink) Delay(20L);strcpy(OpEntryStr,"interm");tmpdone = 1;}
  2663.     if (object == (APTR)&MenuItem8cc) {MoveNow();Delay(50L);strcpy(OpEntryStr,"easy");tmpdone = 1;}
  2664.    }
  2665.   myMenuItem = (struct MenuItem *)object;
  2666.   nextcode = myMenuItem->NextSelect;
  2667.   if (nextcode != MENUNULL)
  2668.    {
  2669.     object = (APTR)ItemAddress(&MenuList1,nextcode);
  2670.    }
  2671.   } while (nextcode != MENUNULL);
  2672.  return(tmpdone);
  2673. }
  2674.  
  2675.  
  2676. void DoAbout()
  2677. {
  2678.  int done=0;
  2679.  struct IntuiMessage __aligned *message;
  2680.  struct Window __aligned *wG3;
  2681.  ULONG class,code;
  2682.  
  2683.  if (!(wG3 = OpenWindow(&NewWindowStructure2)))
  2684.  {
  2685.   DisplayBeep(0L);
  2686.   return;
  2687.  }
  2688.  PrintIText(wG3->RPort,&IText17,0L,0L);
  2689.  do {
  2690.   WaitPort(wG3->UserPort);
  2691.   while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2692.    {
  2693.     class = message->Class;
  2694.     code = message->Code;
  2695.     ReplyMsg((struct Message *)message);
  2696.     if (class == GADGETUP)
  2697.      done = 1;
  2698.     else if (class == VANILLAKEY)
  2699.      {
  2700.       if ((code == 13)||(code == 10))
  2701.        done = 1;
  2702.      }
  2703.    }
  2704.  } while (!done);
  2705.  CloseWindow(wG3);
  2706. }
  2707.  
  2708.  
  2709. void LoadAGame(void)
  2710. {
  2711. // strcpy(OpEntryStr,"get");
  2712.  if (thinkahead)
  2713.    {
  2714.     flag.back = true;
  2715.     while (thinkahead)
  2716.      {
  2717.       Delay(20L);
  2718.      }
  2719.    }
  2720.  GetGame();
  2721. }
  2722.  
  2723. void SaveAGame(void)
  2724. {
  2725. // strcpy(OpEntryStr,"save");
  2726.  if (thinkahead)
  2727.    {
  2728.     flag.back = true;
  2729.     while (thinkahead)
  2730.      {
  2731.       Delay(20L);
  2732.      }
  2733.    }
  2734.  SaveGame();
  2735. }
  2736.  
  2737. void ListAGame(void)
  2738. {
  2739.  if (thinkahead)
  2740.    {
  2741.     flag.back = true;
  2742.     while (thinkahead)
  2743.      {
  2744.       Delay(20L);
  2745.      }
  2746.    }
  2747.  ListGame(0xff);
  2748. }
  2749.  
  2750. void DoQuit(void)
  2751. {
  2752.  flag.quit = true;
  2753. }
  2754.  
  2755. void Go2D(void)
  2756. {
  2757. }
  2758.  
  2759. void DoReverse(void)
  2760. {
  2761. }
  2762.  
  2763. void DoSwap(void)
  2764. {
  2765.  doswap = 1;
  2766. }
  2767.  
  2768. void DoAutoPlay(void)
  2769. {
  2770.  hint = 0;
  2771.  SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  2772.  doauto = 1;
  2773. }
  2774.  
  2775. void MoveNow(void)
  2776. {
  2777.  if ((RealThink))
  2778.   {
  2779.    if (!flag.timeout)
  2780.     {
  2781.      flag.back = true;
  2782.      flag.musttimeout = true;
  2783.     }
  2784.    flag.bothsides = false;
  2785.   }
  2786. }
  2787.  
  2788. void TakeBack(void)
  2789. {
  2790.  char mvnstr[16];
  2791.  int currpiece;
  2792.  long tmp1,tmp2;
  2793.  int r,c,l;
  2794.  
  2795.  
  2796.  if (thinkahead)
  2797.   {
  2798.    flag.back = true;
  2799.    do {
  2800.     Delay(20L);
  2801.    } while(thinkahead);
  2802.   }
  2803.  MoveMem128(amigaboard,board);
  2804.  MoveMem128(amigacolor,color);
  2805.  doundo = 1;
  2806.  hint = 0;
  2807.  if (GameCnt <= 0)
  2808.   return;
  2809.  for (r = 7; r >= 0; r--)
  2810.   {
  2811.    for (c = 0; c <= 7; c++)
  2812.     {
  2813.       l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  2814.       if (amigacolor[l] == neutral)
  2815.     oldboard[r][c] = ' ';
  2816.       else if (amigacolor[l] == white)
  2817.     oldboard[r][c] = qxx[amigaboard[l]];
  2818.       else
  2819.     oldboard[r][c] = pxx[amigaboard[l]];
  2820.     }
  2821.   }
  2822.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  2823.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2824.  LoadBobImage(BLANKDATA);
  2825.  if (SYSTEM_BOBS)
  2826.   {
  2827.    SortGList(rpG);
  2828.    DrawGList(rpG,vP);
  2829.   }
  2830.  Undo();
  2831.  for (r = 7; r >= 0; r--)
  2832.     {
  2833.      for (c = 0; c <= 7; c++)
  2834.       {
  2835.         l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  2836.         if ((color[l] == neutral)&&(oldboard[r][c] != ' '))
  2837.          {
  2838.       tmp1 = r & 1L;
  2839.           tmp2 = c & 1L;
  2840.           if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  2841.            {
  2842.             BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  2843.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2844.             0xc0L,0xffL,0L);
  2845.            }
  2846.           else
  2847.            {
  2848.             BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  2849.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2850.             0xc0L,0xffL,0L);
  2851.            }
  2852.          }
  2853.         else
  2854.          {
  2855.           if (color[l] == white)
  2856.        currpiece = qxx[board[l]];
  2857.           else
  2858.        currpiece = pxx[board[l]];
  2859.           if (currpiece != oldboard[r][c])
  2860.            {
  2861.         tmp1 = r & 1L;
  2862.             tmp2 = c & 1L;
  2863.             if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  2864.              {
  2865.               BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  2866.                 RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2867.                 0xc0L,0xffL,0L);
  2868.              }
  2869.             else
  2870.              {
  2871.               BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  2872.                 RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2873.                 0xc0L,0xffL,0L);
  2874.              }
  2875.         LoadBobImage(currpiece);
  2876.             ClipBlitTrans (
  2877.         &(BobTransImage->ti_RP),    /* Source RastPort */
  2878.              0, 0,        /* Source LeftEdge, TopEdge */
  2879.              rpG,        /* Destination RastPort */
  2880.              ColArray[c],RowArray[r],/* Destination LeftEdge, TopEdge */
  2881.              BobTransImage->ti_IM->Width,    /* Width of Image */
  2882.              BobTransImage->ti_IM->Height,/* Height of Image */
  2883.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  2884.             BobVSprite->X = WIDTH-1-BOBWIDTH;
  2885.             BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2886.             LoadBobImage(BLANKDATA);
  2887.             if (SYSTEM_BOBS)
  2888.              {
  2889.               SortGList(rpG);
  2890.               DrawGList(rpG,vP);
  2891.              }
  2892.            }
  2893.          }
  2894.       }
  2895.     }
  2896.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  2897.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2898.  LoadBobImage(BLANKDATA);
  2899.  if (SYSTEM_BOBS)
  2900.   {
  2901.    SortGList(rpG);
  2902.    DrawGList(rpG,vP);
  2903.   }
  2904.  if (computer != black)
  2905.   mysprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
  2906.  else
  2907.   mysprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
  2908.  ObtainSemaphore(&mySemaphore);
  2909.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  2910.  RectFill(rpG,520,USERBOX,621,USERBOX+30);
  2911.  Move(rpG,520,USERBOX+6);
  2912.  mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  2913.  Text(rpG,mvnstr,strlen(mvnstr));
  2914.  ReleaseSemaphore(&mySemaphore);
  2915. }
  2916.  
  2917. void DoThinking(void)
  2918. {
  2919.  flag.easy = !flag.easy;
  2920. }
  2921.  
  2922. void DoShwThnk(void)
  2923. {
  2924.  flag.post = !flag.post;
  2925. }
  2926.  
  2927. void DoSuper(void)
  2928. {
  2929.  SupervisorMode = !SupervisorMode;
  2930. }
  2931.  
  2932. void DoBookToggle(void)
  2933. {
  2934.     Book = Book ? 0 : BOOKFAIL;
  2935.         bookflag = Book;
  2936. }
  2937.  
  2938. void DoHint(void)
  2939. {
  2940.  GiveHint();
  2941. }
  2942.  
  2943. void DoTest(void)
  2944. {
  2945.  teston = 1;
  2946. }
  2947.  
  2948. int SetAmigaDepth()
  2949. {
  2950.  int dun;
  2951.  struct IntuiMessage __aligned *message;
  2952.  struct Window __aligned *wG3;
  2953.  UWORD __aligned code;
  2954.  ULONG __aligned class;
  2955.  APTR object;
  2956. // ULONG tmp[3];
  2957.  
  2958. // if (DEPTH >= 6)
  2959. //  {
  2960. //   tmp[0] = BigColorPalette[4];
  2961. //   tmp[1] = BigColorPalette[5];
  2962. //   tmp[2] = BigColorPalette[6];
  2963. //   SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  2964. //  }
  2965. // else
  2966. //  {
  2967. //   tmp[0] = myPalette[1];
  2968. //   SetRGB4(vP,1,0xa,0xa,0xa);
  2969. //  }
  2970.  mysprintf(Gadget6SIBuff,"%d",MaxSearchDepth);
  2971.  NewWindowStructure5.FirstGadget = &Gadget6b;
  2972.  if (!(wG3 = OpenWindow(&NewWindowStructure5)))
  2973.  {
  2974.   DisplayBeep(0L);
  2975.   return(0);
  2976.  }
  2977.  Move(wG3->RPort,66,39);
  2978.  Text(wG3->RPort,"Depth",5);
  2979.  ActivateGadget(&Gadget6,wG3,NULL);
  2980.  dun = 0;
  2981.  do {
  2982.  WaitPort(wG3->UserPort);
  2983.  while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2984.   {
  2985.    code = message->Code;
  2986.    object = message->IAddress;
  2987.    class = message->Class;
  2988.    ReplyMsg((struct Message *)message);
  2989. #ifdef SELECTIVEBB
  2990.    if (object != (APTR)&Gadget6b)
  2991.       {
  2992.        dun = 1;
  2993.       }
  2994. #else
  2995.    dun = 1;
  2996. #endif
  2997.   }
  2998.  } while (!dun);
  2999.  CloseWindow(wG3);
  3000. // if (DEPTH >= 6)
  3001. //  {
  3002. //   SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
  3003. //  }
  3004. // else
  3005. //  {
  3006. //   SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
  3007. //  }
  3008.  dun = atoi(Gadget6SIBuff);
  3009.  if (dun > (MAXDEPTH-1))
  3010.   dun = MAXDEPTH -1;
  3011.  if (dun < MINDEPTH)
  3012.   dun = MINDEPTH;
  3013.  NewWindowStructure5.FirstGadget = &Gadget6;
  3014.  return(dun);
  3015. }
  3016.  
  3017. void SetTime(void)
  3018. {
  3019.  int dun;
  3020.  char str[128];
  3021.  struct IntuiMessage __aligned *message;
  3022.  struct Window __aligned *wG3;
  3023.  UWORD __aligned code;
  3024.  ULONG __aligned class;
  3025.  APTR object;
  3026. // ULONG tmp[3];
  3027.  struct Gadget *tg;
  3028.  
  3029. // if (DEPTH >= 6)
  3030. //  {
  3031. //   tmp[0] = BigColorPalette[4];
  3032. //   tmp[1] = BigColorPalette[5];
  3033. //   tmp[2] = BigColorPalette[6];
  3034. //   SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  3035. //  }
  3036.  //else
  3037. //  {
  3038. //   tmp[0] = myPalette[1];
  3039. //   SetRGB4(vP,1,0xa,0xa,0xa);
  3040. //  }
  3041.  mysprintf(Gadget6SIBuff,"%d",TCmoves);
  3042.  mysprintf(Gadget8SIBuff,"%d",(TCminutes));
  3043.  if (!(wG3 = OpenWindow(&NewWindowStructure5)))
  3044.  {
  3045.   DisplayBeep(0L);
  3046.   return;
  3047.  }
  3048.  PrintIText(wG3->RPort,&IText46,0L,0L);
  3049.  ActivateGadget(&Gadget6,wG3,NULL);
  3050.  dun = 0;
  3051.  do {
  3052.  WaitPort(wG3->UserPort);
  3053.  while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  3054.   {
  3055.    code = message->Code;
  3056.    object = message->IAddress;
  3057.    class = message->Class;
  3058.    ReplyMsg((struct Message *)message);
  3059.    if (object != (APTR)&Gadget9)
  3060.       {
  3061.        if (object == (APTR)&Gadget6)
  3062.         {
  3063.          tg = &Gadget8;
  3064.          ActivateGadget(tg,wG3,NULL);
  3065.         }
  3066.        else if (object == (APTR)&Gadget8)
  3067.         dun = 1;
  3068.       }
  3069.      else
  3070.       {
  3071.        dun = 1;
  3072.       }
  3073.   }
  3074.  } while (!dun);
  3075.  CloseWindow(wG3);
  3076. // if (DEPTH >= 6)
  3077. //  {
  3078. //   SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
  3079. //  }
  3080. // else
  3081. //  {
  3082. //   SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
  3083. //  }
  3084.  strcpy(str,Gadget6SIBuff);
  3085.  strcat (str," ");
  3086.  strcat(str,Gadget8SIBuff);
  3087.  SelectLevel(str);
  3088.  et = 0;
  3089.  dun = player;
  3090.  player = white;
  3091.  UpdateClocks();
  3092.  player = black;
  3093.  UpdateClocks();
  3094.  player = dun;
  3095. }
  3096.  
  3097.  
  3098.  
  3099. void DisplayError(str)
  3100. char *str;
  3101. {
  3102.  struct IntuiMessage __aligned *message;
  3103.  struct Window __aligned *wG3;
  3104.  char __aligned c2;
  3105.  char __aligned helpstr[64];
  3106.  BPTR __aligned mywindow;
  3107.  long __aligned temp;
  3108.  
  3109.  DisplayBeep(0L);
  3110.  if (wG)
  3111.   {
  3112.    if (!(wG3 = OpenWindow(&NewWindowStructure2)))
  3113.    {
  3114.     DisplayBeep(0L);
  3115.     return;
  3116.    }
  3117.    Move(wG3->RPort,2,25);
  3118.    Text(wG3->RPort,str,strlen(str));
  3119.    WaitPort(wG3->UserPort);
  3120.    while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  3121.     ReplyMsg((struct Message *)message);
  3122.    CloseWindow(wG3);
  3123.   }
  3124.  else
  3125.   { // open on wb screen
  3126.    (void)WBenchToFront();
  3127.    strcpy(helpstr,"RAW:120/10/400/100/Program Error");
  3128.    if (!(mywindow = Open(helpstr,MODE_NEWFILE)))
  3129.     {
  3130.      DisplayBeep(0L);
  3131.      return;
  3132.     }
  3133.    strcat(str,"\n\n\n");
  3134.    temp = strlen(str);
  3135.    if (Write(mywindow,str,temp) != temp)
  3136.     {
  3137.       DisplayBeep(0L);
  3138.       Close(mywindow);
  3139.       return;
  3140.     }
  3141.    strcpy(helpstr,"      Press any key to continue...");
  3142.    temp = strlen(helpstr);
  3143.    if (Write(mywindow,helpstr,temp) != temp)
  3144.     {
  3145.       DisplayBeep(0L);
  3146.       Close(mywindow);
  3147.       return;
  3148.     }
  3149.    Read(mywindow,&c2,1L);
  3150.    Close(mywindow);
  3151.   }
  3152. }
  3153.  
  3154. struct Library *LhBase;
  3155. struct LhBuffer *myLHBuffer;
  3156.  
  3157. int LoadBobData(void);
  3158. void FreeBobData(void);
  3159. int InitmyGels(void);
  3160. void CloseGels(void);
  3161.  
  3162.  
  3163. void LoadBobImage(piece)
  3164. long piece; /* loads bob with pieces image */
  3165. {
  3166.  int i;
  3167.  UWORD *temp;
  3168.  LONG image_data;
  3169.  WORD planes = RASSIZE (BOBWIDTH, BOBHEIGHT);
  3170.  
  3171.  if (piece == BLANKDATA)
  3172.   {
  3173.    temp = BlankImageData;
  3174.   }
  3175.  else if (piece >= 'a') /* white pieces */
  3176.   {
  3177.    if (piece == 'p')
  3178.     temp = WhiteImageData[0];
  3179.    else if (piece == 'n')
  3180.     temp = WhiteImageData[1];
  3181.    else if (piece == 'b')
  3182.     temp = WhiteImageData[2];
  3183.    else if (piece == 'r')
  3184.     temp = WhiteImageData[3];
  3185.    else if (piece == 'q')
  3186.     temp = WhiteImageData[4];
  3187.    else if (piece == 'k')
  3188.     temp = WhiteImageData[5];
  3189.   }
  3190.  else /* black pieces */
  3191.   {
  3192.    if (piece == 'P')
  3193.     temp = BlackImageData[0];
  3194.    else if (piece == 'N')
  3195.     temp = BlackImageData[1];
  3196.    else if (piece == 'B')
  3197.     temp = BlackImageData[2];
  3198.    else if (piece == 'R')
  3199.     temp = BlackImageData[3];
  3200.    else if (piece == 'Q')
  3201.     temp = BlackImageData[4];
  3202.    else if (piece == 'K')
  3203.     temp = BlackImageData[5];
  3204.   }
  3205.  BobImage.ImageData = BobVSprite->ImageData = temp;
  3206.  image_data = (LONG) BobImage.ImageData;
  3207.  /* Map the image data to planes */
  3208.  for (i = 0L; i < BOBDEPTH; ++i)
  3209.   BobTransImage->ti_BM.Planes[i] = (PLANEPTR) (image_data + i * planes);
  3210.  temp += (BOBHEIGHT*BOBDEPTH*BOBWIDINW);
  3211.  TheBob->ImageShadow = BobVSprite->CollMask = temp;
  3212.  temp += ((BOBHEIGHT+2)*BOBWIDINW);
  3213.  BobVSprite->BorderLine = temp;
  3214.  BobImage.ImageData = BobVSprite->ImageData;
  3215.  BobTransImage->ti_sBM->Planes[0] = (char *)TheBob->ImageShadow;
  3216.  for (i = 1; i < BOBDEPTH; i++)
  3217.    BobTransImage->ti_sBM->Planes[i] = BobTransImage->ti_sBM->Planes[0];
  3218.  lastpiece = piece;
  3219. }
  3220.  
  3221. int LoadBobData()
  3222. {
  3223.  USHORT __aligned len;
  3224.  long __aligned templong;
  3225.  BPTR fh;
  3226.  UBYTE *srcbuf;
  3227.  int i;
  3228.  
  3229.  if (!(srcbuf = AllocMem(BOBBLOCKSIZE,0L)))
  3230.   {
  3231.    return(0);
  3232.   }
  3233.  if (DEPTH < 6)
  3234.   {
  3235.    if (!(fh = Open("uchess:Pieces.lzw",MODE_OLDFILE)))
  3236.     {
  3237.     return(0);
  3238.    }
  3239.   }
  3240.  else if (FasterDisplay)
  3241.   {
  3242.    if (!(fh = Open("uchess:Pieces64.lzw",MODE_OLDFILE)))
  3243.     {
  3244.     return(0);
  3245.    }
  3246.   }
  3247.  else
  3248.   {
  3249.    if (!(fh = Open("uchess:Pieces256.lzw",MODE_OLDFILE)))
  3250.     {
  3251.     return(0);
  3252.    }
  3253.   }
  3254.  if (!(LhBase = OpenLibrary(LH_NAME,LH_VERSION)))
  3255.   {
  3256.    DisplayError("Cannot open lh.lib\n");
  3257.    return(0);
  3258.   }
  3259.  if (!(myLHBuffer = CreateBuffer(TRUE))) /* small buffer for only decomp*/
  3260.   {
  3261.    DisplayError("Cannot Create Buffer\n");
  3262.    CloseLibrary(LhBase);
  3263.    return(0);
  3264.   }
  3265.  for(i=0;i<6;i++)
  3266.   {
  3267.    if (Read(fh,(char *)&len,2L) != 2L)
  3268.     {
  3269.      Close(fh);
  3270.      return(0);
  3271.     }
  3272.    templong = len;
  3273.    if (Read(fh,srcbuf,templong) != templong)
  3274.     {
  3275.      Close(fh);
  3276.      return(0);
  3277.     }
  3278.    if (!(WhiteImageData[i] = 
  3279.         (UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
  3280.     {
  3281.      return(0);
  3282.     }
  3283.    LoadBobImage(piecechar[i]);
  3284.    myLHBuffer->lh_Src = (APTR)srcbuf;
  3285.    myLHBuffer->lh_Dst = (APTR)BobVSprite->ImageData;
  3286.    myLHBuffer->lh_SrcSize = templong;
  3287.    myLHBuffer->lh_DstSize = BOBBLOCKSIZE;
  3288.    LhDecode(myLHBuffer);
  3289.    InitMasks(BobVSprite);
  3290.    if (Read(fh,(char *)&len,2L) != 2L)
  3291.     {
  3292.      Close(fh);
  3293.      return(0);
  3294.     }
  3295.    templong = len;
  3296.    if (Read(fh,srcbuf,templong) != templong)
  3297.     {
  3298.      Close(fh);
  3299.      return(0);
  3300.     }
  3301.    if (!(BlackImageData[i] = 
  3302.         (UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
  3303.     {
  3304.      return(0);
  3305.     }
  3306.    LoadBobImage(piecechar[i+6]);
  3307.    myLHBuffer->lh_Src = (APTR)srcbuf;
  3308.    myLHBuffer->lh_Dst = (APTR)BobVSprite->ImageData;
  3309.    myLHBuffer->lh_SrcSize = templong;
  3310.    myLHBuffer->lh_DstSize = BOBBLOCKSIZE;
  3311.    LhDecode(myLHBuffer);
  3312.    InitMasks(BobVSprite);
  3313.   }
  3314.  Close(fh);
  3315.  FreeMem(srcbuf,BOBBLOCKSIZE);
  3316.  DeleteBuffer(myLHBuffer);
  3317.  CloseLibrary(LhBase);
  3318.  LoadBobImage(BLANKDATA);
  3319.  return(1);
  3320. }
  3321.  
  3322. void FreeBobData()
  3323. {
  3324.  int i;
  3325.  
  3326.  for(i=0;i<6;i++)
  3327.   {
  3328.    FreeMem((char *)WhiteImageData[i],BOBBLOCKSIZE);
  3329.    FreeMem((char *)BlackImageData[i],BOBBLOCKSIZE);
  3330.   }
  3331.  FreeMem((char *)BlankImageData,BOBBLOCKSIZE);
  3332. }
  3333.  
  3334. int InitmyGels()
  3335. {
  3336.  
  3337. #ifdef EXTRAINIT
  3338.  struct BitMap __aligned tmpBitMap;
  3339. #endif
  3340.  int i;
  3341.  UWORD *temp;
  3342.  
  3343.  if (!(SpriteHead = (struct VSprite *)
  3344.        AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
  3345.   {
  3346.    return(0);
  3347.   }
  3348.  if (!(SpriteTail = (struct VSprite *)
  3349.        AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
  3350.   {
  3351.    return(0);
  3352.   }
  3353.  if (!(BobVSprite = (struct VSprite *)
  3354.        AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
  3355.   {
  3356.    return(0);
  3357.   }
  3358.  if (!(TheBob = (struct Bob *)
  3359.        AllocMem(sizeof(struct Bob),MEMF_PUBLIC|MEMF_CLEAR)))
  3360.   {
  3361.    return(0);
  3362.   }
  3363.  if (!(myGelsInfo = (struct GelsInfo *)
  3364.        AllocMem(sizeof(struct GelsInfo),MEMF_PUBLIC|MEMF_CLEAR)))
  3365.   {
  3366.    return(0);
  3367.   }
  3368.  if (!(myGelsInfo->nextLine = (WORD *)AllocMem(sizeof(WORD)*32,
  3369.     MEMF_PUBLIC|MEMF_CLEAR)))
  3370.   {
  3371.    return(0);
  3372.   }
  3373.  if (!(myGelsInfo->lastColor = (WORD **)AllocMem(sizeof(WORD)*32,
  3374.     MEMF_PUBLIC|MEMF_CLEAR)))
  3375.   {
  3376.    return(0);
  3377.   }
  3378.  if (!(myGelsInfo->collHandler = (struct collTable *)
  3379.     AllocMem(sizeof(struct collTable),MEMF_PUBLIC|MEMF_CLEAR)))
  3380.   {
  3381.    return(0);
  3382.   }
  3383.  if (!(TheBob->SaveBuffer = (WORD *)
  3384.     AllocMem(sizeof(SHORT)*BOBWIDINW*BOBHEIGHT*BOBDEPTH,MEMF_CHIP|MEMF_CLEAR)))
  3385.   {
  3386.    return(0);
  3387.   }
  3388.  if (!(temp = BobVSprite->ImageData = 
  3389.         (UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
  3390.     {
  3391.      return(0);
  3392.     }
  3393.  BlankImageData = temp;
  3394.  temp += (BOBHEIGHT*BOBDEPTH*BOBWIDINW);
  3395.  TheBob->ImageShadow = BobVSprite->CollMask = temp;
  3396.  temp += ((BOBHEIGHT+2)*BOBWIDINW);
  3397.  BobVSprite->BorderLine = temp;
  3398. #ifdef DBL_BUFF
  3399.  if (!(TheBob->DBuffer = (struct DBufPacket *)AllocMem
  3400.         (sizeof(struct DBufPacket),MEMF_CHIP|MEMF_CLEAR)))
  3401.     {
  3402.      return(0);
  3403.     }
  3404.  if (!(TheBob->DBuffer->BufBuffer = 
  3405.        (WORD *)AllocRaster(BOBWIDTH,BOBHEIGHT*BOBDEPTH)))
  3406.   {
  3407.      return(0);
  3408.   }
  3409. #endif
  3410.  
  3411.  BOBPLANEPICK = 1;
  3412.  for(i=0;i<DEPTH;i++)
  3413.   {
  3414.    BOBPLANEPICK *= 2;
  3415.   }
  3416.  BOBPLANEPICK--;
  3417.  BobImage.LeftEdge = 0;
  3418.  BobImage.TopEdge = 0;
  3419.  BobImage.Width = BOBWIDTH;
  3420.  BobImage.Height = BOBHEIGHT;
  3421.  BobImage.Depth = BOBDEPTH; 
  3422.  BobImage.ImageData = BobVSprite->ImageData;
  3423.  BobImage.PlanePick = BOBPLANEPICK;
  3424.  BobImage.PlaneOnOff = BOBPLANEONOFF;
  3425.  BobImage.NextImage = NULL;
  3426.  if (!(BobTransImage = AllocTransImage(&BobImage)))
  3427.   {
  3428.    return(0);
  3429.   }
  3430.  
  3431.  if (SYSTEM_BOBS)
  3432.   {
  3433.    myGelsInfo->leftmost = COLA;
  3434.    myGelsInfo->rightmost = COLH+BOBWIDTH+1;
  3435.    myGelsInfo->topmost = ROW8;
  3436.    myGelsInfo->bottommost = ROW1+BOBHEIGHT+1; 
  3437.    rpG->GelsInfo = myGelsInfo;
  3438.    InitGels((struct VSprite *)SpriteHead,SpriteTail,myGelsInfo);
  3439.    WaitTOF();
  3440.   }
  3441.  BobVSprite->Flags = SAVEBACK | OVERLAY;
  3442.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  3443.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;  
  3444.  BobVSprite->Height = BOBHEIGHT;
  3445.  BobVSprite->Width = BOBWIDINW;
  3446.  BobVSprite->Depth = BOBDEPTH;
  3447.  BobVSprite->MeMask = BOBMEMASK;
  3448.  BobVSprite->HitMask = BOBHITMASK;
  3449.  BobVSprite->VSBob = TheBob;
  3450.  BobVSprite->PlanePick = BOBPLANEPICK;
  3451.  BobVSprite->PlaneOnOff = BOBPLANEONOFF;  
  3452.  BobVSprite->VUserExt = 0;
  3453.  TheBob->BobVSprite = BobVSprite;
  3454.  
  3455.  if (!LoadBobData())
  3456.   {
  3457.    DisplayError("Cannot Load BOB data\n");
  3458.    //CloseWindow(wG);
  3459.    CloseScreen(sC);
  3460.   }
  3461.  
  3462.  
  3463.  InitMasks(BobVSprite);
  3464.  return(1);
  3465. }
  3466.  
  3467. void CloseGels()
  3468. {
  3469.      FreeBobData();
  3470.    
  3471. #ifdef DBL_BUFF
  3472.    FreeRaster((PLANEPTR)TheBob->DBuffer->BufBuffer,BOBWIDTH,BOBHEIGHT*BOBDEPTH);
  3473.    FreeMem((char *)TheBob->DBuffer,sizeof(struct DBufPacket));
  3474. #endif
  3475.    FreeTransImage(BobTransImage);
  3476.    FreeMem((char *)TheBob->SaveBuffer,
  3477.      sizeof(SHORT)*BOBWIDINW*BOBHEIGHT*BOBDEPTH);
  3478.    FreeMem((char *)myGelsInfo->collHandler,sizeof(struct collTable));
  3479.    FreeMem((char *)myGelsInfo->lastColor,sizeof(WORD)*32);
  3480.    FreeMem((char *)myGelsInfo->nextLine,sizeof(WORD)*32);
  3481.    FreeMem((char *)myGelsInfo,sizeof(struct GelsInfo));
  3482.    FreeMem((char *)TheBob,sizeof(struct Bob));
  3483.    FreeMem((char *)BobVSprite,sizeof(struct VSprite));
  3484.    FreeMem((char *)SpriteTail,sizeof(struct VSprite));
  3485.    FreeMem((char *)SpriteHead,sizeof(struct VSprite));
  3486. }
  3487.  
  3488. struct TransImage *
  3489. AllocTransImage (struct Image * im)
  3490. {
  3491.     if (im)
  3492.     {
  3493.     LONG msize = sizeof (struct TransImage);
  3494.     struct TransImage *ti;
  3495.  
  3496.     if (ti = (struct TransImage *) AllocMem (msize, MEMF_CLEAR))
  3497.     {
  3498.         LONG image_data = (LONG) im->ImageData;
  3499.         UWORD depth = im->Depth;
  3500.         UWORD width = im->Width;
  3501.         UWORD height = im->Height;
  3502.         WORD planes = RASSIZE (width, height);
  3503.         WORD i;
  3504.  
  3505.         /* Remember the image */
  3506.         ti->ti_IM = im;
  3507.  
  3508.         /* Initialize the Image bitmap */
  3509.         InitBitMap (&ti->ti_BM, depth, width, height);
  3510.  
  3511.         /* Map the image data to planes */
  3512.         for (i = 0L; i < depth; ++i)
  3513.         ti->ti_BM.Planes[i] = (PLANEPTR) (image_data + i * planes);
  3514.  
  3515.         /* Initialize the Image rastport */
  3516.         InitRastPort (&ti->ti_RP);
  3517.         ti->ti_RP.BitMap = &ti->ti_BM;
  3518.  
  3519.         if (ti->ti_sBM = AllocShadowBM (depth, width, height))
  3520.         {
  3521.         if (ti->ti_sRP = AllocShadowRP (ti->ti_sBM))
  3522.         {
  3523.             return (ti);
  3524.         }
  3525.         FreeShadowBM (ti->ti_sBM);
  3526.         }
  3527.         FreeMem ((APTR) ti, msize);
  3528.     }
  3529.     }
  3530.  
  3531.     return (NULL);
  3532. }
  3533.  
  3534. VOID
  3535. FreeTransImage (struct TransImage * ti)
  3536. {
  3537.  
  3538.     if (ti)
  3539.     {
  3540.     LONG msize = sizeof (struct TransImage);
  3541.  
  3542.     /* Free the shadow RastPort */
  3543.     FreeShadowRP (ti->ti_sRP);
  3544.  
  3545.     /* Free the shadow BitMap */
  3546.     FreeShadowBM (ti->ti_sBM);
  3547.  
  3548.     /* Free the temporary buffer */
  3549.     FreeMem ((APTR) ti, msize);
  3550.     }
  3551. }
  3552.  
  3553. VOID
  3554. FreeShadowBM (struct BitMap *sbm)
  3555. {
  3556.  
  3557.     if (sbm)
  3558.     {
  3559.  
  3560. #ifdef ALLOCFORREAL
  3561.     LONG msize;
  3562.  
  3563.     msize = RASSIZE (8 * (sbm->BytesPerRow), sbm->Rows);
  3564.  
  3565.  
  3566.  
  3567.     if (sbm->Planes[0])
  3568.     {
  3569.         FreeMem ((APTR)sbm->Planes[0], msize);
  3570.     }
  3571. #else
  3572.  
  3573.     FreeMem ((APTR)sbm, sizeof (struct BitMap));
  3574. #endif
  3575.     }
  3576. }
  3577.  
  3578. VOID
  3579. FreeShadowRP (struct RastPort *srp)
  3580. {
  3581.  
  3582.     if (srp)
  3583.     {
  3584.     FreeMem (srp, sizeof (struct RastPort));
  3585.     }
  3586. }
  3587.  
  3588. struct BitMap *
  3589. AllocShadowBM (UWORD depth, UWORD width, UWORD height)
  3590. {
  3591.     LONG msize = sizeof (struct BitMap);
  3592.     struct BitMap *bm;
  3593.     WORD i;
  3594.  
  3595.     /* Allocate a bitmap */
  3596.     if (bm = (struct BitMap *) AllocMem (msize, MEMF_CLEAR))
  3597.     {
  3598. #ifdef ALLOCFORREAL
  3599.     LONG rsize = RASSIZE (width, height);
  3600. #endif
  3601.  
  3602.     /* Initialize the bitmap */
  3603.     InitBitMap (bm, depth, width, height);
  3604.  
  3605. #ifdef ALLOCFORREAL
  3606.     /* Allocate one plane */
  3607.     if (bm->Planes[0] = (PLANEPTR) AllocMem (rsize, MEMF_CHIP | MEMF_CLEAR))
  3608.     {
  3609.         /* All planes point to the first plane */
  3610.         for (i = 1; i < depth; i++)
  3611.         bm->Planes[i] = bm->Planes[0];
  3612.  
  3613.         return (bm);
  3614.     }
  3615.  
  3616.     FreeMem ((APTR) bm, msize);
  3617. #else
  3618.      bm->Planes[0] = (char *)TheBob->ImageShadow;
  3619.      for (i = 1; i < depth; i++)
  3620.     bm->Planes[i] = bm->Planes[0];
  3621.      return (bm);
  3622. #endif
  3623.     }
  3624.     return (NULL);
  3625. }
  3626.  
  3627. struct RastPort *
  3628. AllocShadowRP (struct BitMap *bm)
  3629. {
  3630.     LONG msize = sizeof (struct RastPort);
  3631.     struct RastPort *rp;
  3632.  
  3633.     /* Allocate a RastPort */
  3634.     if (rp = (struct RastPort *) AllocMem (msize, MEMF_CHIP))
  3635.     {
  3636.     /* Initialize the new RastPort */
  3637.     InitRastPort (rp);
  3638.  
  3639.     /* Point the RastPort's BitMap... */
  3640.     rp->BitMap = bm;
  3641.     }
  3642.  
  3643.     return (rp);
  3644. }
  3645.  
  3646.  
  3647. VOID
  3648. ClipBlitTrans (
  3649.     struct RastPort *rp,    /* source RastPort */
  3650.     WORD sx, WORD sy,        /* source top-left edge */
  3651.     struct RastPort *drp,    /* destination RastPort */
  3652.     WORD dx, WORD dy,        /* destination top-left edge */
  3653.     WORD width, WORD height,    /* width & height of image to blit */
  3654.     struct RastPort *Srp)    /* shadow RastPort */
  3655. {
  3656.  
  3657.     /* make the shadow */
  3658.     ClipBlit (rp, sx, sy, Srp, 0, 0, width, height, 0xe0);
  3659.     ClipBlit (Srp, 0, 0, drp, dx, dy, width, height, 0x20); /* blit cookie cutter outline */
  3660.     ClipBlit (rp, sx, sy, drp, dx, dy, width, height, 0xe0); /* now fill in image */
  3661. }
  3662.  
  3663.  
  3664. int LoadFullBitMap(void);
  3665.  
  3666. int LoadFullBitMap()
  3667. {
  3668.  unsigned long i;
  3669.  char errstr[40];
  3670.  char fname[80];
  3671.  long count;
  3672.  USHORT len;
  3673.  char *srcbuf;
  3674.  ULONG tt;
  3675.  BPTR fh;
  3676.  BPTR __aligned fp;
  3677.  struct BitMap *tmpBitMap;
  3678.  struct BitMap *PlanarBitMap;
  3679.  struct FileInfoBlock __aligned *myFileInfoBlock;
  3680. //LONG tmp1,tmp2;
  3681. //char tstr[40];
  3682.  
  3683.  if (DEPTH < 6)
  3684.   strcpy(fname,"uchess:Chess.lzw");
  3685.  else if (FasterDisplay)
  3686.   strcpy(fname,"uchess:Chess64.lzw");
  3687.  else
  3688.   strcpy(fname,"uchess:Chess256.lzw");
  3689.  
  3690.  
  3691.   if (!(myFileInfoBlock = 
  3692.      (struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock),MEMF_PUBLIC)))
  3693.    {
  3694.      DisplayError("No Mem now for finfo block");
  3695.      return(0);
  3696.    }
  3697.   if (!(fp = Lock(fname,ACCESS_READ)))
  3698.    {
  3699.      FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
  3700.      return(0);
  3701.    }
  3702.   if (!(Examine(fp,myFileInfoBlock)))
  3703.    {
  3704.      DisplayError("Cannot get finfo");
  3705.      UnLock(fp);
  3706.      FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
  3707.      return(0);
  3708.    }
  3709.   UnLock(fp);
  3710.   count = myFileInfoBlock->fib_Size - 2L;
  3711.   FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
  3712.  
  3713.  
  3714. /* before unpacking the bitmap, save the titlebar area in a tmp bitmap */
  3715.  if (!RTG)
  3716.   {
  3717.    if (!(tmpBitMap = tAllocBitMap(WIDTH,MENUBARHT,DEPTH,BMF_CLEAR,myBitMap)))
  3718.     {
  3719.      return(0);
  3720.     }
  3721.    BltBitMap(myBitMap,0,0,tmpBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
  3722.   }
  3723.  else
  3724.   {
  3725.    if (!(tmpBitMap = tAllocBitMap(WIDTH,MENUBARHT,DEPTH,BMF_CLEAR,0L)))
  3726.     {
  3727.      return(0);
  3728.     }
  3729.    BltBitMap(sC->RastPort.BitMap,0,0,tmpBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
  3730.   }
  3731.  if (!(srcbuf = AllocMem(count,0L)))
  3732.   {
  3733.    sprintf(errstr,"Cannot allocate lharc %d byte buffer",count);
  3734.    DisplayError(errstr);
  3735.    return(0);
  3736.   }
  3737.  if (!(LhBase = OpenLibrary(LH_NAME,LH_VERSION)))
  3738.   {
  3739.    DisplayError("Cannot open lh.lib");
  3740.    return(0);
  3741.   }
  3742.  if (!(myLHBuffer = CreateBuffer(TRUE))) /* small buffer for only decomp*/
  3743.   {
  3744.    DisplayError("Cannot Create Buffer");
  3745.    CloseLibrary(LhBase);
  3746.    return(0);
  3747.   }
  3748.  
  3749.    if (!(fh = Open(fname,MODE_OLDFILE)))
  3750.     {
  3751.      DisplayError("Cannot open chess file");
  3752.      return(0);
  3753.     }
  3754.    if (Read(fh,(char *)&len,2L) != 2L)
  3755.     {
  3756.      DisplayError("Cannot read chess file");
  3757.      Close(fh);
  3758.      return(0);
  3759.     }
  3760.    if (Read(fh,srcbuf,count) != count)
  3761.     {
  3762.      DisplayError("Cannot read chess file2");
  3763.      Close(fh);
  3764.      return(0);
  3765.     }
  3766.    Close(fh);
  3767.    if ((RTG)&&(!OrigmyBitMap))
  3768.     { // allocate the BitMap to unpack to
  3769.      if (!(OrigmyBitMap = myBitMap = sAllocBitMap(WIDTH,HEIGHT,DEPTH,BMF_INTERLEAVED|BMF_CLEAR|BMF_DISPLAYABLE,
  3770.                        0L)))
  3771.       {
  3772.        return(0);
  3773.       }
  3774.     }
  3775.  
  3776.    myLHBuffer->lh_Src = (APTR)srcbuf;
  3777.    myLHBuffer->lh_Dst = (APTR)myBitMap->Planes[0];
  3778.    myLHBuffer->lh_SrcSize = count;
  3779.    tt = WIDTH/8L;
  3780.    tt = tt*HEIGHT;
  3781.    tt = tt*DEPTH;
  3782.    myLHBuffer->lh_DstSize = tt;
  3783.    LhDecode(myLHBuffer);
  3784.  
  3785.  FreeMem(srcbuf,count); 
  3786.  DeleteBuffer(myLHBuffer);
  3787.  CloseLibrary(LhBase);
  3788.  BltBitMap(tmpBitMap,0,0,myBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
  3789.  tFreeBitMap(tmpBitMap);
  3790.  if (RTG)
  3791.   {
  3792.      if (!(PlanarBitMap = tAllocBitMap(WIDTH,HEIGHT/10,DEPTH,BMF_CLEAR,0L)))
  3793.       {
  3794.        return(0);
  3795.       }
  3796.      for(i=0;i<10;i++)
  3797.       {
  3798.        BltBitMap(myBitMap,0,(i*(HEIGHT/10)),PlanarBitMap,0,0,WIDTH,(HEIGHT/10),0xc0L,0xffL,0L);
  3799.        BltBitMap(PlanarBitMap,0,0,sC->RastPort.BitMap,0,(i*(HEIGHT/10)),WIDTH,(HEIGHT/10),0xc0L,0xffL,0L);
  3800.       }
  3801.      // then free the non-interleaved bitmap...
  3802.      tFreeBitMap(PlanarBitMap);
  3803.   }
  3804.  
  3805. #ifdef _M68040
  3806.  strcpy(fname,"UChess Pro:");
  3807. #else
  3808. #ifndef TINYCHESS
  3809.  strcpy(fname,"UChess Jr.:");
  3810. #else
  3811.  strcpy(fname,"UChess Tiny:");
  3812. #endif
  3813. #endif
  3814.  ObtainSemaphore(&mySemaphore);
  3815.  mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  3816.  Move(rpG,511,COMPUTERBOX-10);
  3817.  Text(rpG,fname,strlen(fname));
  3818.  Move(rpG,511,USERBOX-10);
  3819.  strcpy(fname,"Puny Human:");
  3820.  Text(rpG,fname,strlen(fname));
  3821.  ReleaseSemaphore(&mySemaphore);
  3822.  if (!RTG)
  3823.   {
  3824.    BltBitMap(myBitMap,COLB,ROW5,WhiteBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
  3825.    BltBitMap(myBitMap,COLA,ROW5,BlackBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
  3826.   }
  3827.  else
  3828.   {
  3829.    BltBitMap(sC->RastPort.BitMap,COLB,ROW5,WhiteBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
  3830.    BltBitMap(sC->RastPort.BitMap,COLA,ROW5,BlackBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
  3831.   }
  3832.  RethinkDisplay();
  3833.  if (RTG)
  3834.   {
  3835.    myBitMap = sC->RastPort.BitMap;
  3836.    sFreeBitMap(OrigmyBitMap);
  3837.    OrigmyBitMap = 0L;
  3838.   }
  3839.  if (!textBitMap)
  3840.   {
  3841.    if (!(textBitMap = tAllocBitMap(160,160,DEPTH,BMF_CLEAR,myBitMap)))
  3842.     {
  3843.      DisplayBeep(0L);
  3844.      Delay(10L);
  3845.      DisplayBeep(0L);
  3846.      Delay(15L);
  3847.      DisplayBeep(0L);
  3848.      Delay(25L);
  3849.      DisplayBeep(0L);
  3850.      return(0);
  3851.     }
  3852.   }
  3853.  return(1);
  3854. }
  3855.  
  3856.  
  3857. int mAllocBitMap(void);
  3858.  
  3859. int mAllocBitMap()
  3860. {
  3861.  
  3862.  if (!RTG)
  3863.   {
  3864.    if (!(OrigmyBitMap = myBitMap = tAllocBitMap(WIDTH,HEIGHT,DEPTH,BMF_INTERLEAVED|BMF_CLEAR|BMF_DISPLAYABLE,
  3865.                     0L)))
  3866.     {
  3867.      return(0);
  3868.     }
  3869.    tempras_bitplane = AllocMem(WIDTH*HEIGHT/8,MEMF_CLEAR|MEMF_CHIP);
  3870.    if (!tempras_bitplane)
  3871.     {
  3872.      return(0);
  3873.     }
  3874.   }
  3875.  else
  3876.   {
  3877.    if (!(OrigmyBitMap = myBitMap = sAllocBitMap(WIDTH,HEIGHT,DEPTH,BMF_INTERLEAVED|BMF_CLEAR|BMF_DISPLAYABLE,
  3878.                     0L)))
  3879.     {
  3880.      return(0);
  3881.     }
  3882.   }
  3883.  if (RTG)
  3884.   {
  3885.    if ((RTG_ModeID == VGAPRODUCT_KEY)||
  3886.        (RTG_ModeID == (HIRES|LACE|DEFAULT_MONITOR_ID))||
  3887.        (RTG_ModeID == (HIRES|LACE|PAL_MONITOR_ID))|| 
  3888.        (RTG_ModeID == (HIRES|LACE|NTSC_MONITOR_ID)) || 
  3889.        (RTG_ModeID == (HIRES|LACE|DBLPAL_MONITOR_ID))|| 
  3890.        (RTG_ModeID == (HIRES|LACE|DBLNTSC_MONITOR_ID)) || 
  3891.        (RTG_ModeID == (LORES_KEY|LACE|DEFAULT_MONITOR_ID))|| 
  3892.        (RTG_ModeID == (LORES_KEY|LACE|PAL_MONITOR_ID))|| 
  3893.        (RTG_ModeID == (LORES_KEY|LACE|NTSC_MONITOR_ID)) || 
  3894.        (RTG_ModeID == (LORES_KEY|LACE|DBLPAL_MONITOR_ID))|| 
  3895.        (RTG_ModeID == (LORES_KEY|LACE|DBLNTSC_MONITOR_ID)) || 
  3896.        (RTG_ModeID == (HIRES|DEFAULT_MONITOR_ID))||
  3897.        (RTG_ModeID == (HIRES|PAL_MONITOR_ID))|| 
  3898.        (RTG_ModeID == (HIRES|NTSC_MONITOR_ID)) || 
  3899.        (RTG_ModeID == (HIRES|DBLNTSC_MONITOR_ID)) || 
  3900.        (RTG_ModeID == (HIRES|DBLPAL_MONITOR_ID)) || 
  3901.        (RTG_ModeID == (LORES_KEY|DEFAULT_MONITOR_ID))|| 
  3902.        (RTG_ModeID == (LORES_KEY|PAL_MONITOR_ID))|| 
  3903.        (RTG_ModeID == (LORES_KEY|NTSC_MONITOR_ID)) || 
  3904.        (RTG_ModeID == (LORES_KEY|DBLPAL_MONITOR_ID)) || 
  3905.        (RTG_ModeID == (LORES_KEY|DBLNTSC_MONITOR_ID)) || 
  3906.        (RTG_ModeID == (SUPER72_MONITOR_ID | SUPERLACE_KEY)))
  3907.      {
  3908.       myTagList[3].ti_Tag = SA_Interleaved;
  3909.       myTagList[3].ti_Data = TRUE;
  3910.      }
  3911.    NewScreenStructure.Type = CUSTOMSCREEN | NS_EXTENDED; // no custom bitmap
  3912.    NewScreenStructure.CustomBitMap = 0L;
  3913.    if (!(WhiteBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
  3914.                         BMF_CLEAR,0L)))
  3915.     {
  3916.      return(0);
  3917.     }
  3918.    if (!(BlackBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
  3919.                           BMF_CLEAR,0L)))
  3920.     {
  3921.      return(0);
  3922.     }
  3923.   }
  3924.  else
  3925.   {
  3926.    NewScreenStructure.CustomBitMap = myBitMap;
  3927.    if (!(WhiteBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
  3928.                         BMF_CLEAR,myBitMap)))
  3929.     {
  3930.      return(0);
  3931.     }
  3932.    if (!(BlackBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
  3933.                           BMF_CLEAR,myBitMap)))
  3934.     {
  3935.      return(0);
  3936.     }
  3937.   }
  3938.  return(1);
  3939. }
  3940.  
  3941. void FreeTheBitMap(void);
  3942.  
  3943. void FreeTheBitMap()
  3944. {
  3945.  tFreeBitMap(BlackBitMap);
  3946.  tFreeBitMap(WhiteBitMap);
  3947.  if (OrigmyBitMap)
  3948.   if (!RTG)
  3949.    tFreeBitMap(OrigmyBitMap);
  3950.   else
  3951.    sFreeBitMap(OrigmyBitMap);
  3952.  if (textBitMap)
  3953.   tFreeBitMap(textBitMap);
  3954. }
  3955.  
  3956. void AmigaShutDown(void);
  3957. int AmigaStartup(void);
  3958.  
  3959. int AmigaStarted = 0;
  3960.  
  3961. int AmigaStartup()
  3962. {
  3963.     flag.post = false;
  3964.         if (!(myTextFont = OpenFont(&TOPAZ80)))
  3965.          {
  3966.       return(0);
  3967.          }
  3968.         if (gfxversion < 39)
  3969.          DEPTH = 4;
  3970.         else if (RTG)
  3971.          { // use screen requestor to ask guy what he wants
  3972.           if (!GetScreenMode())
  3973.            {
  3974.              return(0);
  3975.            }
  3976.           DEPTH = 8; // only support 8 bit RTG screens
  3977.           myTagList[0].ti_Data = RTG_ModeID;
  3978.       myTagList[2].ti_Tag = SA_AutoScroll;
  3979.           myTagList[2].ti_Data = TRUE;
  3980.          }
  3981.         else
  3982.          {
  3983.           if (v15Khz)
  3984.            {
  3985.             myTagList[0].ti_Data = HIRES|LACE|DEFAULT_MONITOR_ID;
  3986.             myTagList[2].ti_Data = TRUE;
  3987.             myTagList[2].ti_Tag = SA_AutoScroll;
  3988.            }
  3989.           if (Super72)
  3990.            myTagList[0].ti_Data = (SUPER72_MONITOR_ID | SUPERLACE_KEY);
  3991.           NewScreenStructure2.Type |= NS_EXTENDED;
  3992.           NewScreenStructure2.Extension = myTagList;
  3993.           NewScreenStructure2.Height = 480;
  3994.           NewScreenStructure2.Depth = 8; 
  3995.           NewScreenStructure2.BlockPen = 251;
  3996.       if ((sC = OpenScreen((struct NewScreen *)&NewScreenStructure2)))
  3997.            {
  3998.             CloseScreen(sC);
  3999.             DEPTH = 8;
  4000.            }
  4001.           else
  4002.            {
  4003.             myTagList[0].ti_Data = HIRES|LACE|DEFAULT_MONITOR_ID;
  4004.         myTagList[2].ti_Tag = SA_AutoScroll;
  4005.             myTagList[2].ti_Data = TRUE;
  4006.         if ((sC = OpenScreen((struct NewScreen *)&NewScreenStructure2)))
  4007.              {
  4008.               CloseScreen(sC);
  4009.               DEPTH = 8;
  4010.              }
  4011.             else
  4012.              {
  4013.             myTagList[2].ti_Tag = 0;
  4014.               myTagList[2].ti_Data = 0;
  4015.               myTagList[0].ti_Data = HIRES|LACE;
  4016.               DEPTH = 4;
  4017.              }
  4018.            }
  4019.          }
  4020.         if (DEPTH == 8)
  4021.          {
  4022.           BLACK = 2;
  4023.           if (FasterDisplay)
  4024.            {
  4025.             DEPTH = 6;
  4026.             MBLOCKPEN = 0;//61;
  4027.             BACKGNDTEXTCOLOR = 57;
  4028.             BACKPEN =61;
  4029.            }
  4030.           else
  4031.            {
  4032.             MBLOCKPEN = 0;//251;
  4033.             BACKGNDTEXTCOLOR = 0xe0;
  4034.             BACKPEN = 251;
  4035.            }
  4036.       TIMEYCOORD1 = 120;
  4037.       TIMEYCOORD2 = 230;
  4038.           USERBOX=168;
  4039.           SYSTEMBOX = USERBOX + 112;
  4040.           SYSBOXLEN = 102;
  4041.           COMPUTERBOX=60;
  4042.           BOBDEPTH = DEPTH;
  4043.           ROW8 = 24;
  4044.           BOBHEIGHT = 55;
  4045.           HEIGHT = 480;
  4046.           NewScreenStructure.Type |= NS_EXTENDED;
  4047.           NewScreenStructure.Extension = myTagList;
  4048.           NewScreenStructure.Height = HEIGHT;
  4049.           NewScreenStructure.Depth = DEPTH;
  4050.           NewScreenStructure.BlockPen = BACKPEN;
  4051.           NewWindowStructure1.Height = HEIGHT;
  4052.           NewWindowStructure1.MaxHeight = HEIGHT;
  4053.           NewWindowStructure1.BlockPen = BACKPEN;
  4054.           NewWindowStructure2.BlockPen = BACKPEN;
  4055.           NewWindowStructure5.BlockPen = BACKPEN;
  4056.           NewWindowStructure6.BlockPen = BACKPEN;
  4057.           pNewWindowStructure1.BlockPen = BACKPEN;
  4058.           Border6.FrontPen = Border7.FrontPen = 
  4059.           Border9.FrontPen = Border1.FrontPen = BACKPEN;
  4060.           aBorder1.FrontPen = aBorder2.FrontPen = 
  4061.           aBorder3.FrontPen = aBorder4.FrontPen = 
  4062.           pBorder1.FrontPen = pBorder2.FrontPen = 
  4063.           pBorder3.FrontPen = pBorder4.FrontPen = BACKPEN;
  4064.           pIText1.FrontPen = 
  4065.           pIText2.FrontPen = 
  4066.           pIText2a.FrontPen = 
  4067.           pIText3.FrontPen = 
  4068.           pIText4.FrontPen = 
  4069.           pIText5.FrontPen = 
  4070.           pIText6.FrontPen = 
  4071.           pIText7.FrontPen = 
  4072.           pIText8a.FrontPen = 
  4073.           IText93.FrontPen = 
  4074.           IText47.FrontPen = 
  4075.           IText46.FrontPen = 
  4076.           IText37.FrontPen = 
  4077.           IText1.FrontPen = 
  4078.           IText1r.FrontPen = 
  4079.           IText2.FrontPen = 
  4080.           IText2x.FrontPen = 
  4081.           IText3.FrontPen = 
  4082.           IText4.FrontPen = 
  4083.           IText4aa.FrontPen = 
  4084.           IText4ab.FrontPen = 
  4085.           IText4cc.FrontPen = 
  4086.           IText4dd.FrontPen = 
  4087.           IText4ee.FrontPen = 
  4088.           IText4a.FrontPen = 
  4089.           IText5.FrontPen = 
  4090.           IText6.FrontPen = 
  4091.           IText7.FrontPen = 
  4092.           IText8.FrontPen = 
  4093.           IText9.FrontPen = 
  4094.           IText10.FrontPen = 
  4095.           IText11.FrontPen = 
  4096.           IText12.FrontPen = 
  4097.           IText13.FrontPen = 
  4098.           IText13a.FrontPen = 
  4099.           IText14.FrontPen = 
  4100.           IText15.FrontPen = 
  4101.           IText16.FrontPen = 
  4102.           IText22.FrontPen = 
  4103.           IText21.FrontPen = 
  4104.           IText20.FrontPen = 
  4105.           IText19.FrontPen = 
  4106.           IText18.FrontPen = 
  4107.           aIText1.FrontPen = 
  4108.           aIText2.FrontPen = 
  4109.           aIText3.FrontPen = 
  4110.           aIText4.FrontPen = 
  4111.           aIText5.FrontPen = 
  4112.           IText17.FrontPen = BACKPEN;
  4113.  
  4114.           IText37.BackPen = 
  4115.           IText1.BackPen = 
  4116.           IText1r.BackPen = 
  4117.           IText2.BackPen = 
  4118.           IText2x.BackPen = 
  4119.           IText3.BackPen = 
  4120.           IText4.BackPen = 
  4121.           IText4aa.BackPen = 
  4122.           IText4ab.BackPen = 
  4123.           IText4cc.BackPen = 
  4124.           IText4dd.BackPen = 
  4125.           IText4ee.BackPen = 
  4126.           IText4a.BackPen = 
  4127.           IText5.BackPen = 
  4128.           IText6.BackPen = 
  4129.           IText7.BackPen = 
  4130.           IText8.BackPen = 
  4131.           IText9.BackPen = 
  4132.           IText10.BackPen = 
  4133.           IText11.BackPen = 
  4134.           IText12.BackPen = 
  4135.           IText13.BackPen = 
  4136.           IText13a.BackPen = 
  4137.           IText14.BackPen = 
  4138.           IText15.BackPen = BACKPEN;
  4139.  
  4140.           IText37.FrontPen = 
  4141.           IText1.FrontPen = 
  4142.           IText1r.FrontPen = 
  4143.           IText2.FrontPen = 
  4144.           IText2x.FrontPen = 
  4145.           IText3.FrontPen = 
  4146.           IText4.FrontPen = 
  4147.           IText4aa.FrontPen = 
  4148.           IText4ab.FrontPen = 
  4149.           IText4cc.FrontPen = 
  4150.           IText4dd.FrontPen = 
  4151.           IText4ee.FrontPen = 
  4152.           IText4a.FrontPen = 
  4153.           IText5.FrontPen = 
  4154.           IText6.FrontPen = 
  4155.           IText7.FrontPen = 
  4156.           IText8.FrontPen = 
  4157.           IText9.FrontPen = 
  4158.           IText10.FrontPen = 
  4159.           IText11.FrontPen = 
  4160.           IText12.FrontPen = 
  4161.           IText13.FrontPen = 
  4162.           IText13a.FrontPen = 
  4163.           IText14.FrontPen = 
  4164.           IText15.FrontPen = MBLOCKPEN;
  4165.          }
  4166.         if (!(mAllocBitMap()))
  4167.          {
  4168.           CloseFont(myTextFont);
  4169.           return(0);
  4170.          }
  4171.         RowArray[0] = ROW1;
  4172.         RowArray[1] = ROW2;
  4173.         RowArray[2] = ROW3;
  4174.         RowArray[3] = ROW4;
  4175.         RowArray[4] = ROW5;
  4176.         RowArray[5] = ROW6;
  4177.         RowArray[6] = ROW7;
  4178.         RowArray[7] = ROW8;
  4179.     if (!(sC = OpenScreen((struct NewScreen *)&NewScreenStructure)))
  4180.          {
  4181.           if (RTG)
  4182.            {
  4183.           myTagList[2].ti_Tag = 0; // kill autoscroll and try again
  4184.             myTagList[2].ti_Data = 0;
  4185.           if (!(sC = OpenScreen((struct NewScreen *)&NewScreenStructure)))
  4186.              {
  4187.               //FreeTheBitMap();
  4188.               CloseFont(myTextFont);
  4189.               DisplayError("256 color screen in this mode not avail");
  4190.               return(0);
  4191.              }
  4192.            }
  4193.           else // not rtg
  4194.            {
  4195.             FreeTheBitMap();
  4196.             CloseFont(myTextFont);
  4197.             DisplayError("FATAL:Screen mode not avail");
  4198.             return(0);
  4199.            }
  4200.          }
  4201.         vP = &sC->ViewPort;
  4202.         if (DEPTH >= 6)
  4203.          {
  4204.           if (!FasterDisplay)
  4205.          LoadRGB32(&(sC->ViewPort),BigColorPalette);
  4206.           else
  4207.          LoadRGB32(&(sC->ViewPort),Big64Palette);
  4208.          }
  4209.         else
  4210.      LoadRGB4(&(sC->ViewPort),myPalette,16);
  4211.         if (gfxversion > 38)
  4212.          {
  4213.           NewWindowStructure1.Flags |= WFLG_NEWLOOKMENUS;
  4214.          }
  4215.     NewWindowStructure1.Screen = sC;
  4216.     pNewWindowStructure1.Screen = sC;
  4217.     NewWindowStructure2.Screen = sC;
  4218.     NewWindowStructure5.Screen = sC;
  4219.     NewWindowStructure6.Screen = sC;
  4220.         InitSemaphore(&mySemaphore);
  4221.     if (!(InputReply = CreatePort(0L,0L)))
  4222.        {
  4223.           DisplayError("Cannot create reply");
  4224.           return(0);
  4225.          }
  4226.         if (!CreateNewProc(ProcTagList))
  4227.          {
  4228.           DisplayError("Cannot create new proc");
  4229.           return(0);
  4230.          }
  4231.         Delay(15L);
  4232.         while (InputThreadState < 1)
  4233.          Delay(10L);
  4234.         if (InputThreadState != 1)
  4235.          {
  4236.           DisplayError("Trbl with child process");
  4237.           return(0);
  4238.          }
  4239.         Forbid();
  4240.         if (!(InThreadPort = FindPort(InputPortName)))
  4241.           {
  4242.            Permit();
  4243.            DisplayError("Cannot find input port");
  4244.            return(0);
  4245.           }
  4246.         Permit();
  4247.         Global_Message.myData = 0L;
  4248.         Global_Message.MainMsg.mn_Length = sizeof(Global_Message);
  4249.         Global_Message.MainMsg.mn_Node.ln_Type = NT_MESSAGE;
  4250.         Global_Message.MainMsg.mn_ReplyPort = InputReply;
  4251.     rpG = wG->RPort;    /* get a rastport pointer for the window */
  4252.         if (!RTG)
  4253.          {
  4254.           InitTmpRas(&temp_rast,tempras_bitplane,WIDTH*HEIGHT/8);
  4255.           rpG->TmpRas = &temp_rast;
  4256.          }
  4257.     SetFont(rpG,myTextFont);
  4258.         Delay(25L); /* crashes from wb if I do not do this! */
  4259.         SetDrMd(rpG,JAM1);
  4260.         if (!InitmyGels())
  4261.          {
  4262.       CloseScreen(sC);
  4263.           CloseFont(myTextFont);
  4264. //          FreeTheBitMap();
  4265.           return(0);
  4266.          }
  4267.         else
  4268.          {
  4269.           if (!LoadFullBitMap())
  4270.            {
  4271.             //CloseWindow(wG);
  4272.             CloseScreen(sC);
  4273.            return(0);
  4274.            }
  4275. // finish GEL init and add the bob
  4276.           if (SYSTEM_BOBS)
  4277.            AddBob(TheBob,rpG);
  4278.       WaitTOF();
  4279.        MakeScreen(sC);
  4280.       RethinkDisplay();
  4281.        if (SYSTEM_BOBS)
  4282.           {
  4283.            SortGList(rpG);
  4284.            DrawGList(rpG,vP);
  4285.            MakeVPort(GfxBase->ActiView,vP);
  4286.            MrgCop(GfxBase->ActiView);
  4287.            WaitTOF();
  4288.            SortGList(rpG);
  4289.            DrawGList(rpG,vP);
  4290.            MakeVPort(GfxBase->ActiView,vP);
  4291.            MrgCop(GfxBase->ActiView);
  4292.           WaitTOF();
  4293.           SortGList(rpG);
  4294.            DrawGList(rpG,vP);
  4295.         }
  4296.       MakeVPort(GfxBase->ActiView,vP);
  4297.       MrgCop(GfxBase->ActiView);
  4298.        WaitTOF();
  4299.           MakeScreen(sC);
  4300.        RethinkDisplay();
  4301.        WaitTOF();
  4302.           AmigaStarted = 1;
  4303.           if (gfxversion > 38)
  4304.         bpen = GetBPen(rpG);
  4305.       return(1);
  4306.          }
  4307. }
  4308.  
  4309.  
  4310.  
  4311. void AmigaShutDown()
  4312. {
  4313.  int tmpargcnt;
  4314.  
  4315. // need to wake up the input thread so it can exit 1st
  4316.     Global_Message.myData = 0xff;
  4317.     Forbid();
  4318.     PutMsg(InThreadPort,(struct Message *)&Global_Message);
  4319.     Permit();
  4320.     tmpargcnt = 0;
  4321.     Delay(25L);
  4322.     while ((InputThreadState < 2)&&(tmpargcnt < 10))
  4323.      {
  4324.       tmpargcnt++;
  4325.       Delay(25L);
  4326.      }
  4327.     CloseGels();
  4328.     CloseScreen(sC);
  4329.     if (!RTG)
  4330.      {
  4331.       if (tempras_bitplane)
  4332.        FreeMem(tempras_bitplane,WIDTH*HEIGHT/8);
  4333.      }
  4334.     FreeTheBitMap();
  4335.     CloseFont(myTextFont);
  4336.     if (InputReply)
  4337.      DeletePort(InputReply);
  4338. }
  4339.  
  4340. void ShowMessage(str)
  4341. char *str;
  4342. {
  4343.  char tstr[16];
  4344.  int done = 0;
  4345.  int i=0;
  4346.  int j,k,lim;
  4347.  int ycoord;
  4348.  
  4349.  if (str[strlen(str)-1] == '\n')
  4350.   {
  4351.    str[strlen(str)-1] = 0;
  4352.   }
  4353.  ycoord = SYSTEMBOX+6;
  4354. /* scroll down 3 lines (30 pixels) */
  4355.  ObtainSemaphore(&mySemaphore);
  4356.  BltBitMap(myBitMap,510,SYSTEMBOX,textBitMap,0L,0L,621-510+1,SYSBOXLEN,0xc0L,0xffL,0L);
  4357.  BltBitMap(textBitMap,0,0,myBitMap,510,SYSTEMBOX+30,621-510+1,SYSBOXLEN-30,0xc0L,0xffL,0L);
  4358.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  4359.  RectFill(rpG,510,SYSTEMBOX-1,621,SYSTEMBOX+29);
  4360.  ReleaseSemaphore(&mySemaphore);
  4361.  do {
  4362.  j = i;
  4363.  if (strlen(str) <= 14)
  4364.   {
  4365.    done = 1;
  4366.    strcpy(tstr,str);
  4367.   }
  4368.  else
  4369.   {
  4370.    lim = j + 14;
  4371.    if (lim >= strlen(str))
  4372.     {
  4373.      done = 1;
  4374.      lim = strlen(str);
  4375.     }
  4376.    for(k=0;i<lim;i++,k++)
  4377.     tstr[k] = str[i];
  4378.    tstr[k] = 0;
  4379.   }
  4380.  ObtainSemaphore(&mySemaphore);
  4381.  mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  4382.  Move(rpG,510,ycoord); /* was 509,ycord */
  4383.  Text(rpG,tstr,strlen(tstr));
  4384.  ReleaseSemaphore(&mySemaphore);
  4385.  ycoord += 10;
  4386.  } while (!done);
  4387. }
  4388.  
  4389.  
  4390.  
  4391. void DisplayComputerMove(str)
  4392. char *str;
  4393. {
  4394.  char tstr[16];
  4395.  int done = 0;
  4396.  int i=0;
  4397.  int j,k,lim;
  4398.  int ycoord;
  4399.  
  4400.  if (str[strlen(str)-1] == '\n')
  4401.   {
  4402.    str[strlen(str)-1] = 0;
  4403.   }
  4404.  ObtainSemaphore(&mySemaphore);
  4405.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  4406.  RectFill(rpG,520,COMPUTERBOX,621,COMPUTERBOX+30);
  4407.  ReleaseSemaphore(&mySemaphore);
  4408.  ycoord = COMPUTERBOX+6;
  4409.  do {
  4410.  j = i;
  4411.  if (strlen(str) <= 12)
  4412.   {
  4413.    done = 1;
  4414.    strcpy(tstr,str);
  4415.   }
  4416.  else
  4417.   {
  4418.    lim = j + 12;
  4419.    if (lim >= strlen(str))
  4420.     {
  4421.      done = 1;
  4422.      lim = strlen(str);
  4423.     }
  4424.    for(k=0;i<lim;i++,k++)
  4425.     tstr[k] = str[i];
  4426.    tstr[k] = 0;
  4427.   }
  4428.  ObtainSemaphore(&mySemaphore);
  4429.  mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  4430.  Move(rpG,520,ycoord);
  4431.  Text(rpG,tstr,strlen(tstr));
  4432.  ReleaseSemaphore(&mySemaphore);
  4433.  ycoord += 10;
  4434.  } while (!done);
  4435. }
  4436.  
  4437. void DoLegalMove(str)
  4438. char *str;
  4439. {
  4440.  long mpiece;
  4441.  char piece;
  4442.  int r,c,l;
  4443.  int ecol,erow,scol,srow,side,tmp1,tmp2,incrx,incry,i;
  4444.  
  4445.    if (SYSTEM_BOBS)
  4446.     {
  4447.      SortGList(rpG);
  4448.      DrawGList(rpG,vP);
  4449.     }
  4450.    MakeVPort(GfxBase->ActiView,vP);
  4451.    MrgCop(GfxBase->ActiView);
  4452.    if (SYSTEM_BOBS)
  4453.     {
  4454.      RemIBob(TheBob,rpG,vP);
  4455.      SortGList(rpG);
  4456.      DrawGList(rpG,vP);
  4457.     }
  4458.    MakeVPort(GfxBase->ActiView,vP);
  4459.    MrgCop(GfxBase->ActiView);
  4460.    r = str[3] - '1';
  4461.    c = str[2] - 'a';
  4462.    tmp1 = r & 1;
  4463.    tmp2 = c & 1;
  4464.    if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4465.     {
  4466.      BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  4467.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  4468.             0xc0L,0xffL,0L);
  4469.     }
  4470.    else
  4471.     {
  4472.      BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  4473.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  4474.             0xc0L,0xffL,0L);
  4475.     }
  4476.    MakeVPort(GfxBase->ActiView,vP);
  4477.    MrgCop(GfxBase->ActiView);
  4478.    RethinkDisplay();
  4479.    WaitTOF();
  4480.    l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  4481.    if ((color[l] == neutral))
  4482.     {
  4483.      ExitChess();
  4484.      return;
  4485.     }
  4486.    else if (color[l] == white)
  4487.     piece = qxx[board[l]]; /* white are lower case pieces */
  4488.    else
  4489.     piece = pxx[board[l]]; /* black are upper case pieces */
  4490.    if ((DestRow == 7)||(!DestRow))
  4491.     { /* possible promotion */
  4492.       mpiece = piece;
  4493.       LoadBobImage(mpiece);
  4494.     }
  4495.    ClipBlitTrans (
  4496.         &(BobTransImage->ti_RP),    /* Source RastPort */
  4497.              0, 0,        /* Source LeftEdge, TopEdge */
  4498.              rpG,        /* Destination RastPort */
  4499.              ColArray[DestCol],RowArray[DestRow],/* Destination LeftEdge, TopEdge */
  4500.              BobTransImage->ti_IM->Width,    /* Width of Image */
  4501.              BobTransImage->ti_IM->Height,/* Height of Image */
  4502.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  4503.    BobVSprite->X = WIDTH-1-BOBWIDTH;
  4504.    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4505.    LoadBobImage(BLANKDATA);
  4506.    if (SYSTEM_BOBS)
  4507.     {
  4508.      AddBob(TheBob,rpG);
  4509.      SortGList(rpG);
  4510.      DrawGList(rpG,vP);
  4511.     }
  4512.    MakeVPort(GfxBase->ActiView,vP);
  4513.    MrgCop(GfxBase->ActiView);
  4514.    if (piece >= 'a')
  4515.     {
  4516.      mpiece = 'r';
  4517.      srow = 0;
  4518.      erow = 0;
  4519.      side = white;
  4520.      if (str[2] == 'g') /* king side white */
  4521.       {
  4522.        scol = 7;
  4523.        ecol = 5;
  4524.       }
  4525.      else
  4526.       {
  4527.        ecol = 3;
  4528.        scol = 0;
  4529.       }
  4530.     }
  4531.    else
  4532.     {
  4533.      mpiece = 'R';
  4534.      srow = 7;
  4535.      erow = 7;
  4536.      side = black;
  4537.      if (str[2] == 'g') /* king side black */
  4538.       {
  4539.        scol = 7;
  4540.        ecol = 5;
  4541.       }
  4542.      else
  4543.       {
  4544.        ecol = 3;
  4545.        scol = 0;
  4546.       }
  4547.     }
  4548.    if (Castled[side])
  4549.     {
  4550.      Castled[side] = 0;
  4551.      tmp1 = srow & 1;
  4552.      tmp2 = scol & 1;
  4553.      if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4554.       {
  4555.        BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  4556.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4557.             0xc0L,0xffL,0L);
  4558.       }
  4559.      else
  4560.       {
  4561.        BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  4562.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4563.             0xc0L,0xffL,0L);
  4564.       }
  4565.      BobVSprite->X = ColArray[scol];
  4566.      BobVSprite->Y = RowArray[srow];
  4567.      if (SYSTEM_BOBS)
  4568.       {
  4569.        SortGList(rpG);
  4570.        DrawGList(rpG,vP);
  4571.       }
  4572.      MakeVPort(GfxBase->ActiView,vP);
  4573.      MrgCop(GfxBase->ActiView);
  4574.      LoadBobImage(mpiece);
  4575.      if (SYSTEM_BOBS)
  4576.       {
  4577.        SortGList(rpG);
  4578.        DrawGList(rpG,vP);
  4579.       }
  4580.      MakeVPort(GfxBase->ActiView,vP);
  4581.      MrgCop(GfxBase->ActiView);
  4582.      incry = (RowArray[erow] - RowArray[srow])/8;
  4583.      incrx = (ColArray[ecol] - ColArray[scol])/8;
  4584.      for(i=0;i<8;i++)
  4585.       {
  4586.        BobVSprite->X += incrx;
  4587.        BobVSprite->Y += incry;
  4588.        if (SYSTEM_BOBS)
  4589.         {
  4590.          SortGList(rpG);
  4591.          DrawGList(rpG,vP);
  4592.         }
  4593.        MakeVPort(GfxBase->ActiView,vP);
  4594.        MrgCop(GfxBase->ActiView);
  4595.       }
  4596.      if (SYSTEM_BOBS)
  4597.       {
  4598.        RemIBob(TheBob,rpG,vP);
  4599.        SortGList(rpG);
  4600.        DrawGList(rpG,vP);
  4601.       }
  4602.      MakeVPort(GfxBase->ActiView,vP);
  4603.      MrgCop(GfxBase->ActiView);
  4604.      ClipBlitTrans (
  4605.             &(BobTransImage->ti_RP),    /* Source RastPort */
  4606.                  0, 0,        /* Source LeftEdge, TopEdge */
  4607.                  rpG,        /* Destination RastPort */
  4608.                  ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
  4609.                  BobTransImage->ti_IM->Width,    /* Width of Image */
  4610.                  BobTransImage->ti_IM->Height,/* Height of Image */
  4611.                  BobTransImage->ti_sRP);    /* Shadow RastPort */
  4612.      LoadBobImage(BLANKDATA);
  4613.      if (SYSTEM_BOBS)
  4614.       {
  4615.        AddBob(TheBob,rpG);
  4616.       }
  4617.      MakeVPort(GfxBase->ActiView,vP);
  4618.      MrgCop(GfxBase->ActiView);
  4619.     }
  4620.    else /* check EnPassant */
  4621.     {
  4622.      side ^= 1;
  4623.      if (myEnPassant[side])
  4624.       {
  4625.        myEnPassant[side] = 0;
  4626.        scol = str[2] - 'a';
  4627.        if (str[3] == '3') /* white is removed from bd at 4*/
  4628.         {
  4629.          srow = 3;
  4630.         }
  4631.        else /* black is removed at pos 5 */
  4632.         {
  4633.          srow = 4;
  4634.         }
  4635.        tmp1 = srow & 1;
  4636.        tmp2 = scol & 1;
  4637.        if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4638.         {
  4639.          BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  4640.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4641.             0xc0L,0xffL,0L);
  4642.         }
  4643.        else
  4644.         {
  4645.          BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  4646.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4647.             0xc0L,0xffL,0L);
  4648.         }
  4649.       }
  4650.     }
  4651. }
  4652.  
  4653. void DrawAmigaBoard()
  4654. {
  4655.  int r,c,l,tmp1,tmp2;
  4656.  int piece;
  4657.  
  4658.  LoadBobImage(BLANKDATA);
  4659.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  4660.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4661.  if (SYSTEM_BOBS)
  4662.   {
  4663.    SortGList(rpG);
  4664.    DrawGList(rpG,vP);
  4665.    RemIBob(TheBob,rpG,vP);
  4666.    SortGList(rpG);
  4667.    DrawGList(rpG,vP);
  4668.   }
  4669.  for(r=0;r<8;r++)
  4670.   for(c=0;c<8;c++)
  4671.    {
  4672.        tmp1 = r & 1;
  4673.        tmp2 = c & 1;
  4674.        if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4675.         {
  4676.          BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  4677.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  4678.             0xc0L,0xffL,0L);
  4679.         }
  4680.        else
  4681.         {
  4682.          BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  4683.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  4684.             0xc0L,0xffL,0L);
  4685.         }    
  4686.     l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  4687.     if (color[l] == white)
  4688.      piece = qxx[board[l]]; /* white are lower case pieces */
  4689.     else
  4690.      piece = pxx[board[l]]; /* black are upper case pieces */
  4691.     if (color[l] != neutral)
  4692.      {
  4693.       BobVSprite->X = ColArray[c];
  4694.       BobVSprite->Y = RowArray[r];
  4695.       LoadBobImage(piece);
  4696.       ClipBlitTrans (
  4697.         &(BobTransImage->ti_RP),    /* Source RastPort */
  4698.              0, 0,        /* Source LeftEdge, TopEdge */
  4699.              rpG,        /* Destination RastPort */
  4700.              ColArray[c],RowArray[r],/* Destination LeftEdge, TopEdge */
  4701.              BobTransImage->ti_IM->Width,    /* Width of Image */
  4702.              BobTransImage->ti_IM->Height,/* Height of Image */
  4703.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  4704.      }
  4705.    }
  4706.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  4707.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4708.  LoadBobImage(BLANKDATA);
  4709.  if (SYSTEM_BOBS)
  4710.   AddBob(TheBob,rpG);
  4711. }
  4712.  
  4713.  
  4714. #define INPUTSIGNAL (1<<InputPort->mp_SigBit)
  4715.  
  4716. void __saveds InputThread()
  4717. {
  4718.  struct IntuiMessage __aligned *message;
  4719.  struct myMsgStruct *InputMsg;
  4720.  ULONG cmd; 
  4721.  struct MsgPort *InputPort;
  4722.  
  4723. // Init The Port We will use to communicate
  4724.  InputThreadState = 0;
  4725.  wG = OpenWindow(&NewWindowStructure1);    /* open the window */
  4726.  if ( wG == NULL )
  4727.   {
  4728.    CloseScreen(sC);
  4729.    CloseFont(myTextFont);
  4730.    FreeTheBitMap();
  4731.    InputThreadState = 0x7ffe;
  4732.   }
  4733.  else // window opened
  4734.   {
  4735.    globalsignalset = WINDOWSIGNAL;
  4736.    if (!(InputPort = CreatePort(InputPortName,0)))
  4737.     {
  4738.      InputThreadState = 0x7fff;
  4739.     }
  4740.    else
  4741.     {
  4742.      InputThreadState = 1;
  4743.      do {
  4744.        if (Wait(INPUTSIGNAL) & INPUTSIGNAL)
  4745.         {
  4746.          InputMsg = (struct myMsgStruct *)GetMsg(InputPort);
  4747.          cmd = InputMsg->myData;
  4748.          if (!flag.quit)
  4749.           {
  4750.            if (cmd == 1L) // do get op entry
  4751.             {
  4752.              OpEntryRecvd = 0;
  4753.              do {
  4754.              GetOperatorEntry(); // TMP DEBUG COMMENTED OUT!
  4755.              if ((!OpEntryRecvd)&&(!RealThink)) // do not set if already set by movenow
  4756.               OpEntryRecvd = 1;
  4757.              if (OpEntryRecvd)
  4758.               ReplyMsg((struct Message *)InputMsg); // let caller know you are done
  4759.              } while (!OpEntryRecvd);
  4760.             }
  4761.           }
  4762.         }
  4763.        else
  4764.         { // strange wake up should not happen
  4765.         }
  4766.      } while ((cmd != 0xff));
  4767.     } // input port ok
  4768.    ClearPointer(wG);
  4769.    if (SYSTEM_BOBS)
  4770.     RemIBob(TheBob,rpG,vP);
  4771.    while(message = (struct IntuiMessage *)GetMsg(wG->UserPort))
  4772.     ReplyMsg((struct Message *)message);
  4773.    CloseWindow(wG);
  4774.    wG = 0L;
  4775.   } // window opened
  4776.  DeletePort(InputPort);
  4777.  Forbid(); // make sure we end first!
  4778.  InputThreadState = 2;
  4779. }
  4780.  
  4781. void GetOperatorEntry(void)
  4782. {
  4783.  char *str;
  4784.  char __aligned PromoteChar;
  4785.  char mvnstr[32];
  4786.  ULONG signals;
  4787.  char __aligned tempstr[40];
  4788.  struct IntuiMessage __aligned *message;
  4789.  long done=0;
  4790.  long done2;
  4791.  int ilen=0;
  4792.  int r,c,l,piece;
  4793.  long __aligned class,code;
  4794.  int MouseX,MouseY;
  4795.  long tmp1,tmp2;
  4796.  int tmovenum;
  4797.  static int movenum;
  4798.  
  4799.  
  4800.  
  4801.  str = OpEntryStr;
  4802.  if (CheckIllegal)
  4803.   {
  4804.    CheckIllegal = 0;
  4805.    if (IllegalMove)
  4806.     { /* put guy back! */
  4807.       IllegalMove = 0;
  4808.       if (SYSTEM_BOBS)
  4809.        {
  4810.         RemIBob(TheBob,rpG,vP);
  4811.         SortGList(rpG); 
  4812.         DrawGList(rpG,vP);
  4813.        }
  4814.       MakeVPort(GfxBase->ActiView,vP);
  4815.       MrgCop(GfxBase->ActiView);
  4816.       ClipBlitTrans (
  4817.         &(BobTransImage->ti_RP),    /* Source RastPort */
  4818.              0, 0,        /* Source LeftEdge, TopEdge */
  4819.              rpG,        /* Destination RastPort */
  4820.              ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
  4821.              BobTransImage->ti_IM->Width,    /* Width of Image */
  4822.              BobTransImage->ti_IM->Height,/* Height of Image */
  4823.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  4824.       BobVSprite->X = WIDTH-1-BOBWIDTH;
  4825.       BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4826.       LoadBobImage(BLANKDATA);
  4827.       if (SYSTEM_BOBS)
  4828.        AddBob(TheBob,rpG);
  4829.       MakeVPort(GfxBase->ActiView,vP);
  4830.       MrgCop(GfxBase->ActiView);
  4831.     }
  4832.   }
  4833.  while (message = (struct IntuiMessage *)GetMsg(wG->UserPort))
  4834.    {
  4835.      ReplyMsg((struct Message *)message);
  4836.    }
  4837. // when an illegal move is made
  4838. // the tmovenum used to be 1 too many for computer == black
  4839.  if (!thinkahead)
  4840.   {
  4841.    if (computer == white)
  4842.     {
  4843.       movenum = (GameCnt)>>1;
  4844.     }
  4845.    else
  4846.     {
  4847.      movenum = (GameCnt+1)>>1; // was +2
  4848.     }
  4849.   }
  4850.  else
  4851.   {
  4852.     movenum++;
  4853.   }
  4854.  if (!GameCnt)
  4855.   tmovenum = 1;
  4856.  else
  4857.   {
  4858.    if (thinkahead)
  4859.     {
  4860.     if (computer == white)
  4861.      {
  4862.       tmovenum = movenum - 1;
  4863.      }
  4864.     else
  4865.      tmovenum = movenum;
  4866.     }
  4867.    else
  4868.     {
  4869.      tmovenum = movenum + 1;
  4870.     }
  4871.   }
  4872.  if (tmovenum < 1)
  4873.   tmovenum = 1;
  4874.  mysprintf(mvnstr,"%d: ",tmovenum);
  4875.  ObtainSemaphore(&mySemaphore);
  4876.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  4877.  RectFill(rpG,520,USERBOX,621,USERBOX+30);
  4878.  Move(rpG,520,USERBOX+6);
  4879.  mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  4880.  Text(rpG,mvnstr,strlen(mvnstr));
  4881.  ReleaseSemaphore(&mySemaphore);
  4882.  tempstr[0] = 0;
  4883.  PromoteChar = 0;
  4884.  OnMenu(wG,SHOWMENUNUM); 
  4885.  OnMenu(wG,SUPERMENUNUM); 
  4886.  OnMenu(wG,THINKMENUNUM); 
  4887.  OnMenu(wG,BOOKMENUNUM); 
  4888.  do {
  4889. // if (!globalmessage_valid)
  4890. //  signals = Wait(globalsignalset);
  4891.  WaitPort(wG->UserPort);
  4892. // if ((signals & WINDOWSIGNAL)||(globalmessage_valid))
  4893. //  {
  4894. //  message = (struct IntuiMessage *)1;
  4895.   while ((message = (struct IntuiMessage *)GetMsg(wG->UserPort)))
  4896.   {
  4897.   //if (!globalmessage_valid)
  4898.    //message = (struct IntuiMessage *)GetMsg(wG->UserPort);
  4899.   //if ((message)) //||(globalmessage_valid))
  4900.    //{
  4901.    //     if (!globalmessage_valid)
  4902.    //      {
  4903.          class = message->Class;
  4904.       code = message->Code;
  4905.           MouseX = message->MouseX;
  4906.           MouseY = message->MouseY;
  4907.       ReplyMsg((struct Message *)message);
  4908. //         }
  4909. //        else
  4910. //         {
  4911. //      class = globalmessage.Class;
  4912. //      code = globalmessage.Code;
  4913. //          MouseX = globalmessage.MouseX;
  4914. //          MouseY = globalmessage.MouseY;
  4915. //          globalmessage_valid = 0L;
  4916. //         }
  4917.         if (RealThink)
  4918.          { // we are in the middle of Selectmove iop == 1!!
  4919.           if (class == MENUPICK)
  4920.            {
  4921.             if (code != MENUNULL)
  4922.              {
  4923.            done = HandleEvent((APTR)ItemAddress(&MenuList1,code));
  4924.               if (done)
  4925.                strcpy(tempstr,OpEntryStr);
  4926.              }
  4927.            }
  4928.           else if ((class == MOUSEBUTTONS)&&(code == SELECTDOWN))
  4929.            {
  4930.             if (flag.bothsides)
  4931.              {
  4932.               if (!flag.timeout)
  4933.                {
  4934.                 flag.back = true;
  4935.                }
  4936.               flag.bothsides = false;
  4937.              }
  4938.            }
  4939.          }
  4940.     else if ( class == MENUPICK )    /* MenuItems */
  4941.          { // ! realthink
  4942.           if (code != MENUNULL)
  4943.            {
  4944.          done = HandleEvent((APTR)ItemAddress(&MenuList1,code));
  4945.             if (done)
  4946.              strcpy(tempstr,OpEntryStr);
  4947.             if (flag.quit) 
  4948.              done = 1;
  4949.             else if (!done)
  4950.              {
  4951.               if (teston)
  4952.                {
  4953.                 done = 1;
  4954.                 teston = 0;
  4955.                 strcpy(tempstr,"test");
  4956.                }
  4957.               else if (doswap)
  4958.                {
  4959.                 done = 1;
  4960.                 doswap = 0;
  4961.                 strcpy(tempstr,"switch");
  4962.                }
  4963.               else if (doauto)
  4964.                {
  4965.                 done = 1;
  4966.                 doauto = 0;
  4967.                 strcpy(tempstr,"both");
  4968.                }
  4969.               else if (doundo)
  4970.                {
  4971.                 done = 1;
  4972.                 doundo = 0;
  4973.                 strcpy(tempstr,"help");
  4974.                }
  4975.              }
  4976.            }
  4977.          }
  4978.     else if ((class == RAWKEY) && (!RealThink))
  4979.      {
  4980.           if (code < 80)
  4981.            {
  4982.           code = cookedchar[code];
  4983.           if ((code == 13)||(code == 10))
  4984.        {
  4985.             if (tempstr[0])
  4986.              done = 1;
  4987.        }
  4988.           else if ((code == 7)&&(ilen)) /* backspace */
  4989.            {
  4990.             tempstr[strlen(tempstr)-1] = '\0';
  4991.             mysprintf(mvnstr,"%d: ",tmovenum);
  4992.             ObtainSemaphore(&mySemaphore);
  4993.             mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  4994.             RectFill(rpG,520,USERBOX,621,USERBOX+30);
  4995.             mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  4996.             Move(rpG,520,USERBOX+6);
  4997.             Text(rpG,mvnstr,strlen(mvnstr));
  4998.             Text(rpG,tempstr,strlen(tempstr));
  4999.             ReleaseSemaphore(&mySemaphore);
  5000.             ilen--;
  5001.            }
  5002.           else if ((isalnum(code)||(code == '-')||(code == '/')) && (strlen(tempstr) < 12))
  5003.            {
  5004.             tempstr[ilen] = tolower(code);
  5005.             ilen++;
  5006.             tempstr[ilen] = 0;
  5007.             mysprintf(mvnstr,"%d: ",tmovenum);
  5008.             ObtainSemaphore(&mySemaphore);
  5009.             mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  5010.             Move(rpG,520,USERBOX+6);
  5011.             Text(rpG,mvnstr,strlen(mvnstr));
  5012.             Text(rpG,tempstr,strlen(tempstr));
  5013.             ReleaseSemaphore(&mySemaphore);
  5014.            }
  5015.           } /* code < 80 */
  5016.      }
  5017.         else if ((class == MOUSEBUTTONS)&&(!(flag.quit || flag.mate || flag.force))
  5018.                    &&(!RealThink))
  5019.          {
  5020.           if ((code == SELECTDOWN) && 
  5021.               ((MouseY <= (ROW1+SQUAREHEIGHT)) && (MouseY >= ROW8) && (MouseX <= (COLH+BOBWIDTH)) &&
  5022.                (MouseX >= COLA)))
  5023.            {
  5024.             if (MouseX < COLB)
  5025.              OrigCol = 0;
  5026.             else if (MouseX < COLC)
  5027.              OrigCol = 1;
  5028.             else if (MouseX < COLD)
  5029.              OrigCol = 2;
  5030.             else if (MouseX < COLE)
  5031.              OrigCol = 3;
  5032.             else if (MouseX < COLF)
  5033.              OrigCol = 4;
  5034.             else if (MouseX < COLG)
  5035.              OrigCol = 5;
  5036.             else if (MouseX < COLH)
  5037.              OrigCol = 6;
  5038.             else 
  5039.              OrigCol = 7;
  5040.             if (MouseY < ROW7)
  5041.              OrigRow = 7;
  5042.             else if (MouseY < ROW6)
  5043.              OrigRow = 6;
  5044.             else if (MouseY < ROW5)
  5045.              OrigRow = 5;
  5046.             else if (MouseY < ROW4)
  5047.              OrigRow = 4;
  5048.             else if (MouseY < ROW3)
  5049.              OrigRow = 3;
  5050.             else if (MouseY < ROW2)
  5051.              OrigRow = 2;
  5052.             else if (MouseY < ROW1)
  5053.              OrigRow = 1;
  5054.             else 
  5055.              OrigRow = 0;
  5056.             tmp1 = OrigRow & 1L;
  5057.             tmp2 = OrigCol & 1L;
  5058.             done2 = 0;
  5059.             r = OrigRow;
  5060.             c = OrigCol;
  5061.             l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  5062.             if ((amigacolor[l] == neutral)||(opponent != amigacolor[l]))
  5063.              {
  5064.               done2 = 1;
  5065.              }
  5066.             else if (amigacolor[l] == white)
  5067.              piece = qxx[amigaboard[l]]; /* white are lower case pieces */
  5068.             else
  5069.              piece = pxx[amigaboard[l]]; /* black are upper case pieces */
  5070.             if (!done2)
  5071.              {
  5072.               if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  5073.                {
  5074.                 BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[OrigCol],
  5075.             RowArray[OrigRow],SQUAREWIDTH,SQUAREHEIGHT,
  5076.             0xc0L,0xffL,0L);
  5077.                }
  5078.               else
  5079.                {
  5080.                 BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[OrigCol],
  5081.             RowArray[OrigRow],SQUAREWIDTH,SQUAREHEIGHT,
  5082.             0xc0L,0xffL,0L);
  5083.                }
  5084.               BobVSprite->X = WIDTH-1-BOBWIDTH;
  5085.               BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  5086.               LoadBobImage(BLANKDATA);
  5087.               if (SYSTEM_BOBS)
  5088.                {
  5089.                 SortGList(rpG);
  5090.                 DrawGList(rpG,vP);
  5091.                }
  5092.               MakeVPort(GfxBase->ActiView,vP);
  5093.               MrgCop(GfxBase->ActiView);
  5094.               CheckIllegal = 1;
  5095.               IllegalMove = 0;
  5096.  /* NOW POSITION BOB AND LOAD IN ITS CORRECT PIECE IMAGE */
  5097.           LoadBobImage(piece);
  5098.               BobVSprite->X = MouseX - 24;
  5099.               BobVSprite->Y = MouseY - 16;
  5100.               if (SYSTEM_BOBS)
  5101.                {
  5102.                 SortGList(rpG);
  5103.                 DrawGList(rpG,vP);
  5104.                }
  5105.               MakeVPort(GfxBase->ActiView,vP);
  5106.               MrgCop(GfxBase->ActiView);
  5107.              }
  5108.             ModifyIDCMP(wG,NewWindowStructure1.IDCMPFlags | INTUITICKS);
  5109.             do {
  5110.             signals = Wait(globalsignalset);
  5111.             if (signals & WINDOWSIGNAL)
  5112.              {
  5113.               while ( (message = (struct IntuiMessage *)
  5114.           GetMsg(wG->UserPort) ))
  5115.               {
  5116.           class = message->Class;
  5117.           code = message->Code;
  5118.               MouseX = message->MouseX;
  5119.               MouseY = message->MouseY;
  5120.           ReplyMsg((struct Message *)message);
  5121.               if (!done2)
  5122.                {
  5123.               if ((class == MOUSEBUTTONS)&&(code == SELECTUP))
  5124.                { /* now try and make the move */
  5125.                 done2 = 1;
  5126.         if ((MouseX > (COLH+SQUAREWIDTH)) || (MouseX < COLA) ||
  5127.                     (MouseY < ROW8) || (MouseY > (ROW1+BOBHEIGHT)))
  5128.                  { /* Put the Piece Back */
  5129.                    BobVSprite->X = WIDTH-1-BOBWIDTH;
  5130.                    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  5131.                    tmp1 = lastpiece;
  5132.            LoadBobImage(BLANKDATA);
  5133.                    if (SYSTEM_BOBS)
  5134.                     {
  5135.                      SortGList(rpG);
  5136.                      DrawGList(rpG,vP);
  5137.                      RemIBob(TheBob,rpG,vP);
  5138.                      SortGList(rpG);
  5139.                      DrawGList(rpG,vP);
  5140.                     }
  5141.                    MakeVPort(GfxBase->ActiView,vP);
  5142.                    MrgCop(GfxBase->ActiView);
  5143.            LoadBobImage(tmp1);
  5144.                    ClipBlitTrans (
  5145.               &(BobTransImage->ti_RP),    /* Source RastPort */
  5146.               0, 0,        /* Source LeftEdge, TopEdge */
  5147.               rpG,        /* Destination RastPort */
  5148.               ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
  5149.               BobTransImage->ti_IM->Width,    /* Width of Image */
  5150.               BobTransImage->ti_IM->Height,/* Height of Image */
  5151.               BobTransImage->ti_sRP);    /* Shadow RastPort */
  5152.                    BobVSprite->X = WIDTH-1-BOBWIDTH;
  5153.                    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  5154.                    LoadBobImage(BLANKDATA);
  5155.                    if (SYSTEM_BOBS)
  5156.                     {
  5157.                      AddBob(TheBob,rpG);
  5158.                      SortGList(rpG);
  5159.                      DrawGList(rpG,vP);
  5160.                     }
  5161.                    MakeVPort(GfxBase->ActiView,vP);
  5162.                    MrgCop(GfxBase->ActiView);
  5163.                  }
  5164.                 else
  5165.                  {
  5166.                   done = 1; /* try the move */
  5167.                   if (MouseX < COLB)
  5168.                    DestCol = 0;
  5169.                   else if (MouseX < COLC)
  5170.                    DestCol = 1;
  5171.                   else if (MouseX < COLD)
  5172.                    DestCol = 2;
  5173.                   else if (MouseX < COLE)
  5174.                    DestCol = 3;
  5175.                   else if (MouseX < COLF)
  5176.                    DestCol = 4;
  5177.                   else if (MouseX < COLG)
  5178.                    DestCol = 5;
  5179.                   else if (MouseX < COLH)
  5180.                    DestCol = 6;
  5181.                   else 
  5182.                    DestCol = 7;
  5183.                   if (MouseY < ROW7)
  5184.                    DestRow = 7;
  5185.                   else if (MouseY < ROW6)
  5186.                    DestRow = 6;
  5187.                   else if (MouseY < ROW5)
  5188.                    DestRow = 5;
  5189.                   else if (MouseY < ROW4)
  5190.                    DestRow = 4;
  5191.                   else if (MouseY < ROW3)
  5192.                    DestRow = 3;
  5193.                   else if (MouseY < ROW2)
  5194.                    DestRow = 2;
  5195.                   else if (MouseY < ROW1)
  5196.                    DestRow = 1;
  5197.                   else 
  5198.                    DestRow = 0;
  5199.                   if ((DestRow == OrigRow) && (DestCol == OrigCol))
  5200.                    {
  5201.                     done = 0;
  5202.             tmp1 = lastpiece;
  5203.             LoadBobImage(BLANKDATA);
  5204.                     BobVSprite->X = WIDTH-1-BOBWIDTH;
  5205.                     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  5206.                     if (SYSTEM_BOBS)
  5207.                      {
  5208.                       SortGList(rpG);
  5209.                       DrawGList(rpG,vP);
  5210.                       RemIBob(TheBob,rpG,vP);
  5211.                       SortGList(rpG);
  5212.                       DrawGList(rpG,vP);
  5213.                      }
  5214.                     MakeVPort(GfxBase->ActiView,vP);
  5215.                     MrgCop(GfxBase->ActiView);
  5216.             LoadBobImage(tmp1);
  5217.                     ClipBlitTrans (
  5218.             &(BobTransImage->ti_RP),    /* Source RastPort */
  5219.                  0, 0,        /* Source LeftEdge, TopEdge */
  5220.                  rpG,        /* Destination RastPort */
  5221.                  ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
  5222.                  BobTransImage->ti_IM->Width,    /* Width of Image */
  5223.                  BobTransImage->ti_IM->Height,/* Height of Image */
  5224.                  BobTransImage->ti_sRP);    /* Shadow RastPort */
  5225.                     BobVSprite->X = WIDTH-1-BOBWIDTH;
  5226.                     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  5227.                     LoadBobImage(BLANKDATA);
  5228.                     if (SYSTEM_BOBS)
  5229.                      {
  5230.                       AddBob(TheBob,rpG);
  5231.                       SortGList(rpG);
  5232.                       DrawGList(rpG,vP);
  5233.                      }
  5234.                     MakeVPort(GfxBase->ActiView,vP);
  5235.                     MrgCop(GfxBase->ActiView);
  5236.                    }
  5237.                   else
  5238.                   {
  5239.                    MouseDropped = 1;
  5240.             if (((piece == 'p')&&(DestRow == 7))||/* possible prom wht */
  5241.                        ((piece == 'P')&&(!DestRow))) /* possible blk promotion */
  5242.                      {
  5243.                       PromoteChar = DisplayPromoteRequestor();
  5244.                      }
  5245.                    tempstr[4] = 0;
  5246.                    tempstr[0] = OrigCol + 'a';
  5247.                    tempstr[1] = OrigRow + '1';
  5248.                    tempstr[2] = DestCol + 'a';
  5249.                    tempstr[3] = DestRow + '1';
  5250.                    mysprintf(mvnstr,"%d: ",tmovenum);
  5251.                    ObtainSemaphore(&mySemaphore);
  5252.                    mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  5253.                    Move(rpG,520,USERBOX+6);
  5254.                    Text(rpG,mvnstr,strlen(mvnstr));
  5255.                    Text(rpG,tempstr,strlen(tempstr));
  5256.                    ReleaseSemaphore(&mySemaphore);
  5257.            if ((thinkahead)&&(!flag.bothsides))
  5258.                     { // code to abort quickly and drop piece!
  5259.                      (void)SetTaskPri((struct Task *)myproc,procpri);
  5260.                      if (!TCflag)
  5261.                       backsrchaborted = 1;
  5262.                      if (!flag.timeout)
  5263.                       {
  5264.                        flag.back = true;
  5265.                       }
  5266.                     }
  5267.                   }
  5268.                  }
  5269.                }
  5270.               else if (class == INTUITICKS)
  5271.                {
  5272.                 BobVSprite->X = MouseX - 24;
  5273.                 BobVSprite->Y = MouseY - 16;
  5274.                 if (SYSTEM_BOBS)
  5275.                  {
  5276.                   SortGList(rpG);
  5277.                   DrawGList(rpG,vP);
  5278.                  }
  5279.                 MakeVPort(GfxBase->ActiView,vP);
  5280.                 MrgCop(GfxBase->ActiView);
  5281.                }
  5282.                } /* ! done2 */
  5283.               }
  5284.              } /* signals & WINDOWSIGNAL */
  5285.             } while (!done2);
  5286.             ModifyIDCMP(wG,NewWindowStructure1.IDCMPFlags);
  5287.             while ( (message = (struct IntuiMessage *)
  5288.          GetMsg(wG->UserPort) ))
  5289.              {
  5290.           ReplyMsg((struct Message *)message);
  5291.              }
  5292.            }
  5293.          }
  5294.    //} // if message
  5295. //    if (done)
  5296. //     {
  5297. //       while ((message = (struct IntuiMessage *)GetMsg(wG->UserPort)))
  5298. //      ReplyMsg((struct Message *)message);
  5299. //     }
  5300.   } /* while message */
  5301.   //} /* signals & windowsignal */
  5302.   } while (!done);
  5303. OffMenu(wG,SHOWMENUNUM); 
  5304. OffMenu(wG,BOOKMENUNUM); 
  5305. OffMenu(wG,SUPERMENUNUM); 
  5306. OffMenu(wG,THINKMENUNUM); 
  5307. if (tempstr[0])
  5308.  {
  5309.   if (tempstr[2] == '-')
  5310.    {
  5311.     for(ilen=2;ilen<strlen(tempstr);ilen++)
  5312.      tempstr[ilen] = tempstr[ilen+1];
  5313.    }
  5314.   if (tempstr[4] == '/')
  5315.    {
  5316.     for(ilen=4;ilen<strlen(tempstr);ilen++)
  5317.      tempstr[ilen] = tempstr[ilen+1];
  5318.    }
  5319.  }
  5320. if ((!PromoteChar)&&((strlen(tempstr) == 2) || (strlen(tempstr) == 4)))
  5321.  {
  5322.   r = tempstr[1] - '1';
  5323.   if ((strlen(tempstr) == 2)&&(opponent == white))
  5324.    {
  5325.     r--;
  5326.    }
  5327.   else if ((strlen(tempstr) == 2)&&(opponent == black))
  5328.    {
  5329.     r++;
  5330.    }
  5331.   c = tempstr[0] - 'a';
  5332.   l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  5333.   if ((amigacolor[l] == neutral)||(opponent != amigacolor[l]))
  5334.    {
  5335.     done2 = 1;
  5336.    }
  5337.   else if (amigacolor[l] == white)
  5338.    piece = qxx[amigaboard[l]]; /* white are lower case pieces */
  5339.   else
  5340.    piece = pxx[amigaboard[l]]; /* black are upper case pieces */
  5341.   if (strlen(tempstr) == 4)
  5342.    {
  5343.      r = tempstr[3] - '1';
  5344.    }
  5345.   else
  5346.    {
  5347.     if (opponent == white)
  5348.      {
  5349.       r++;
  5350.      }
  5351.      else
  5352.      {
  5353.       r--;
  5354.      }
  5355.    }
  5356.   if (((piece == 'p')&&(r == 7))||/* possible prom wht */
  5357.       ((piece == 'P')&&(!r))) /* possible blk promotion */
  5358.     {
  5359.      PromoteChar = DisplayPromoteRequestor();
  5360.      if (strlen(tempstr) == 2)
  5361.       {
  5362.        if (!r)
  5363.         {
  5364.          tempstr[4] = 0;
  5365.          tempstr[3] = tempstr[1];
  5366.          tempstr[2] = tempstr[0];
  5367.          tempstr[1]++;
  5368.         }
  5369.        else
  5370.         {
  5371.          tempstr[4] = 0;
  5372.          tempstr[3] = tempstr[1];
  5373.          tempstr[2] = tempstr[0];
  5374.          tempstr[1]--;  
  5375.         }
  5376.       }
  5377.     }
  5378.  }
  5379. if (PromoteChar)
  5380.  {
  5381.   ilen = strlen(tempstr);
  5382.   tempstr[ilen] = PromoteChar;
  5383.   tempstr[ilen+1] = 0;
  5384.  }
  5385. strcpy(str,tempstr);
  5386. if (!(stricmp(str,"new")))
  5387.  {
  5388.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  5389.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  5390.     LoadBobImage(BLANKDATA);
  5391.     if (SYSTEM_BOBS)
  5392.      {
  5393.       SortGList(rpG);
  5394.       DrawGList(rpG,vP);
  5395.      }
  5396.     MakeVPort(GfxBase->ActiView,vP);
  5397.     MrgCop(GfxBase->ActiView);
  5398.     WaitTOF();
  5399.     RethinkDisplay();
  5400.  }
  5401. }
  5402.  
  5403. void AnimateAmigaMove(str,piece)
  5404. char *str;
  5405. char piece; /* black are upper case pieces, white lower case */
  5406. {
  5407.  int side;
  5408.  int tmp1,tmp2;
  5409.  int srow,scol,erow,ecol,incrx,incry,i;
  5410.  long mpiece;
  5411.  
  5412.  
  5413.  if ((piece == ' ')||(flag.quit))
  5414.   return;
  5415.  mpiece = piece;
  5416.  if (!MouseDropped)
  5417.   {
  5418.    BobVSprite->X = WIDTH-1-BOBWIDTH;
  5419.    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  5420.    LoadBobImage(BLANKDATA);
  5421.    if (SYSTEM_BOBS)
  5422.     {
  5423.      SortGList(rpG);
  5424.      DrawGList(rpG,vP);
  5425.     }
  5426.    MakeVPort(GfxBase->ActiView,vP);
  5427.    MrgCop(GfxBase->ActiView);
  5428.    scol = str[0] - 'a';
  5429.    srow = str[1] - '1';
  5430.    ecol = str[2] - 'a';
  5431.    erow = str[3] - '1';
  5432.    tmp1 = srow & 1;
  5433.    tmp2 = scol & 1;
  5434.    if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  5435.     {
  5436.      BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  5437.         RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5438.         0xc0L,0xffL,0L);
  5439.     }
  5440.    else
  5441.     {
  5442.      BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  5443.         RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5444.         0xc0L,0xffL,0L);
  5445.     }
  5446.    tmp1 = erow & 1;
  5447.    tmp2 = ecol & 1;
  5448.    if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  5449.     {
  5450.      BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[ecol],
  5451.         RowArray[erow],SQUAREWIDTH,SQUAREHEIGHT,
  5452.         0xc0L,0xffL,0L);
  5453.     }
  5454.    else
  5455.     {
  5456.      BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[ecol],
  5457.         RowArray[erow],SQUAREWIDTH,SQUAREHEIGHT,
  5458.         0xc0L,0xffL,0L);
  5459.     }
  5460.    BobVSprite->X = ColArray[scol];
  5461.    BobVSprite->Y = RowArray[srow];
  5462.    LoadBobImage(mpiece);
  5463.    if (SYSTEM_BOBS)
  5464.     {
  5465.      SortGList(rpG);
  5466.      DrawGList(rpG,vP);
  5467.     }
  5468.    MakeVPort(GfxBase->ActiView,vP);
  5469.    MrgCop(GfxBase->ActiView);
  5470.    incry = (RowArray[erow] - RowArray[srow])/8;
  5471.    incrx = (ColArray[ecol] - ColArray[scol])/8;
  5472.    for(i=0;i<8;i++)
  5473.     {
  5474.      BobVSprite->X += incrx;
  5475.      BobVSprite->Y += incry;
  5476.      if (SYSTEM_BOBS)
  5477.       {
  5478.        SortGList(rpG);
  5479.        DrawGList(rpG,vP);
  5480.       }
  5481.      MakeVPort(GfxBase->ActiView,vP);
  5482.      MrgCop(GfxBase->ActiView);
  5483.     }
  5484.    if (SYSTEM_BOBS)
  5485.     {
  5486.      RemIBob(TheBob,rpG,vP);
  5487.      SortGList(rpG);
  5488.      DrawGList(rpG,vP);
  5489.     }
  5490.    MakeVPort(GfxBase->ActiView,vP);
  5491.    MrgCop(GfxBase->ActiView);
  5492.    ClipBlitTrans (
  5493.         &(BobTransImage->ti_RP),    /* Source RastPort */
  5494.              0, 0,        /* Source LeftEdge, TopEdge */
  5495.              rpG,        /* Destination RastPort */
  5496.              ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
  5497.              BobTransImage->ti_IM->Width,    /* Width of Image */
  5498.              BobTransImage->ti_IM->Height,/* Height of Image */
  5499.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  5500.    BobVSprite->X = WIDTH-1-BOBWIDTH;
  5501.    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  5502.    LoadBobImage(BLANKDATA);
  5503.    if (SYSTEM_BOBS)
  5504.     {
  5505.      AddBob(TheBob,rpG);
  5506.     }
  5507.    MakeVPort(GfxBase->ActiView,vP);
  5508.    MrgCop(GfxBase->ActiView);
  5509.    if (piece >= 'a')
  5510.     {
  5511.      mpiece = 'r';
  5512.      srow = 0;
  5513.      erow = 0;
  5514.      side = white;
  5515.      if (str[2] == 'g') /* king side white */
  5516.       {
  5517.        scol = 7;
  5518.        ecol = 5;
  5519.       }
  5520.      else
  5521.       {
  5522.        ecol = 3;
  5523.        scol = 0;
  5524.       }
  5525.     }
  5526.    else
  5527.     {
  5528.      mpiece = 'R';
  5529.      srow = 7;
  5530.      erow = 7;
  5531.      side = black;
  5532.      if (str[2] == 'g') /* king side black */
  5533.       {
  5534.        scol = 7;
  5535.        ecol = 5;
  5536.       }
  5537.      else
  5538.       {
  5539.        ecol = 3;
  5540.        scol = 0;
  5541.       }
  5542.     }
  5543.    if (Castled[side])
  5544.     {
  5545.      Castled[side] = 0;
  5546.      tmp1 = srow & 1;
  5547.      tmp2 = scol & 1;
  5548.      if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  5549.       {
  5550.        BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  5551.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5552.             0xc0L,0xffL,0L);
  5553.       }
  5554.      else
  5555.       {
  5556.        BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  5557.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5558.             0xc0L,0xffL,0L);
  5559.       }
  5560.      BobVSprite->X = ColArray[scol];
  5561.      BobVSprite->Y = RowArray[srow];
  5562.      if (SYSTEM_BOBS)
  5563.       {
  5564.        SortGList(rpG);
  5565.        DrawGList(rpG,vP);
  5566.       }
  5567.      MakeVPort(GfxBase->ActiView,vP);
  5568.      MrgCop(GfxBase->ActiView);
  5569.      LoadBobImage(mpiece);
  5570.      if (SYSTEM_BOBS)
  5571.       {
  5572.        SortGList(rpG);
  5573.        DrawGList(rpG,vP);
  5574.       }
  5575.      MakeVPort(GfxBase->ActiView,vP);
  5576.      MrgCop(GfxBase->ActiView);
  5577.      incry = (RowArray[erow] - RowArray[srow])/8;
  5578.      incrx = (ColArray[ecol] - ColArray[scol])/8;
  5579.      for(i=0;i<8;i++)
  5580.       {
  5581.        BobVSprite->X += incrx;
  5582.        BobVSprite->Y += incry;
  5583.        if (SYSTEM_BOBS)
  5584.         {
  5585.          SortGList(rpG);
  5586.          DrawGList(rpG,vP);
  5587.         }
  5588.        MakeVPort(GfxBase->ActiView,vP);
  5589.        MrgCop(GfxBase->ActiView);
  5590.       }
  5591.      if (SYSTEM_BOBS)
  5592.       {
  5593.        RemIBob(TheBob,rpG,vP);
  5594.        SortGList(rpG);
  5595.        DrawGList(rpG,vP);
  5596.       }
  5597.      MakeVPort(GfxBase->ActiView,vP);
  5598.      MrgCop(GfxBase->ActiView);
  5599.      ClipBlitTrans (
  5600.             &(BobTransImage->ti_RP),    /* Source RastPort */
  5601.                  0, 0,        /* Source LeftEdge, TopEdge */
  5602.                  rpG,        /* Destination RastPort */
  5603.                  ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
  5604.                  BobTransImage->ti_IM->Width,    /* Width of Image */
  5605.                  BobTransImage->ti_IM->Height,/* Height of Image */
  5606.                  BobTransImage->ti_sRP);    /* Shadow RastPort */
  5607.      LoadBobImage(BLANKDATA);
  5608.      if (SYSTEM_BOBS)
  5609.       {
  5610.        AddBob(TheBob,rpG);
  5611.       }
  5612.      MakeVPort(GfxBase->ActiView,vP);
  5613.      MrgCop(GfxBase->ActiView);
  5614.     }
  5615.    else /* check EnPassant */
  5616.     {
  5617.      side ^= 1;
  5618.      if (myEnPassant[side])
  5619.       {
  5620.        myEnPassant[side] = 0;
  5621.        scol = str[2] - 'a';
  5622.        if (str[3] == '3') /* white is removed from bd at 4*/
  5623.         {
  5624.          srow = 3;
  5625.         }
  5626.        else /* black is removed at pos 5 */
  5627.         {
  5628.          srow = 4;
  5629.         }
  5630.        tmp1 = srow & 1;
  5631.        tmp2 = scol & 1;
  5632.        if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  5633.         {
  5634.          BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  5635.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5636.             0xc0L,0xffL,0L);
  5637.         }
  5638.        else
  5639.         {
  5640.          BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  5641.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5642.             0xc0L,0xffL,0L);
  5643.         }
  5644.       }
  5645.     }
  5646.   }
  5647. }
  5648.  
  5649. #endif /* AMIGA */
  5650.  
  5651.  
  5652. void GetTimeString(str)
  5653. char *str;
  5654. {
  5655. #ifdef AMIGA
  5656. #endif
  5657. }
  5658.  
  5659.  
  5660.  
  5661. char __aligned *ColorStr[2];
  5662. char __far __aligned *CP[CPSIZE];
  5663. /*
  5664.  * In a networked enviroment gnuchess might be compiled on different hosts
  5665.  * with different random number generators, that is not acceptable if they
  5666.  * are going to share the same transposition table.
  5667.  */
  5668.  
  5669. unsigned int urand (void);
  5670.  
  5671.  
  5672. unsigned long __aligned hashkey, hashbd;
  5673. #ifdef LONGINTS2
  5674. struct hashval __far hashcode[2][7][64];
  5675. #else
  5676. struct hashval __aligned hashcode[2][7][64];
  5677. #endif
  5678.  
  5679. #ifdef CACHE
  5680. #ifdef ttblsz
  5681. struct hashentry huge __aligned *ttable[2];
  5682. unsigned int __aligned ttblsize;
  5683. #endif
  5684.  
  5685. #else
  5686.  
  5687. #ifdef ttblsz
  5688. struct hashentry __aligned __far ttable[2][vttblsz + MAXrehash];
  5689. unsigned int __aligned ttblsize;
  5690. #endif
  5691.  
  5692. #endif
  5693.  
  5694. char __far __aligned savefile[128] = "";
  5695. char __far __aligned listfile[128] = "";
  5696. #ifdef HISTORY
  5697. unsigned char __far __aligned history[32768];
  5698. #endif
  5699. INTSIZE __aligned rpthash[2][256];
  5700. struct leaf __far __aligned Tree[TREE];
  5701. struct leaf  __aligned *root;
  5702. INTSIZE __aligned TrPnt[MAXDEPTH];
  5703. INTSIZE __aligned PieceList[2][64], PawnCnt[2][8];
  5704. INTSIZE __aligned castld[2], Mvboard[64];
  5705. INTSIZE __aligned svalue[64];
  5706. struct flags __aligned flag;
  5707. INTSIZE __aligned opponent, computer, WAwindow, WBwindow, BAwindow, BBwindow, dither, INCscore;
  5708. long __aligned ResponseTime, ExtraTime, MaxResponseTime, et, et0, time0, ft;
  5709. long __aligned GenCnt, NodeCnt, ETnodes, EvalNodes, HashCnt, HashAdd, FHashCnt, FHashAdd, HashCol,
  5710.  THashCol, filesz;
  5711. long __aligned replus, reminus;
  5712. INTSIZE __aligned HashDepth = HASHDEPTH, HashMoveLimit = HASHMOVELIMIT;
  5713. INTSIZE __aligned player, xwndw, rehash;
  5714. struct GameRec __aligned GameList[MAXMOVES + MAXDEPTH];
  5715. INTSIZE __aligned Sdepth, GameCnt, Game50, MaxSearchDepth;
  5716. INTSIZE __aligned epsquare, contempt;
  5717. int __aligned Book;
  5718. struct TimeControlRec __aligned TimeControl;
  5719. INTSIZE __aligned TCflag, TCmoves, TCminutes, TCseconds, OperatorTime;
  5720. INTSIZE __aligned XCmoves[3], XCminutes[3], XCseconds[3], XC, XCmore;
  5721. const INTSIZE __aligned otherside[3] =
  5722. {black, white, neutral};
  5723. unsigned INTSIZE __aligned hint;
  5724. INTSIZE int __aligned TOflag;        /* force search re-init if we backup search */
  5725.  
  5726. INTSIZE __aligned mtl[2], pmtl[2], hung[2];
  5727. INTSIZE __aligned Pindex[64];
  5728. INTSIZE __aligned PieceCnt[2];
  5729. INTSIZE __aligned FROMsquare, TOsquare;
  5730. INTSIZE __aligned HasKnight[2], HasBishop[2], HasRook[2], HasQueen[2];
  5731. INTSIZE __aligned ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], PawnThreat[MAXDEPTH];
  5732. INTSIZE __aligned Pscore[MAXDEPTH], Tscore[MAXDEPTH];
  5733. const INTSIZE __aligned qrook[3] =
  5734. {0, 56, 0};
  5735. const INTSIZE __aligned krook[3] =
  5736. {7, 63, 0};
  5737. const INTSIZE __aligned kingP[3] =
  5738. {4, 60, 0};
  5739. const INTSIZE __aligned rank7[3] =
  5740. {6, 1, 0};
  5741. const INTSIZE __aligned sweep[8] =
  5742. {false, false, false, true, true, true, false, false};
  5743. unsigned INTSIZE __aligned killr0[MAXDEPTH], killr1[MAXDEPTH];
  5744. unsigned INTSIZE __aligned killr2[MAXDEPTH], killr3[MAXDEPTH];
  5745. unsigned INTSIZE __aligned PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4;
  5746.  
  5747. #ifdef USE_SIDEBIT
  5748. unsigned INTSIZE __aligned sidebit;
  5749. #endif
  5750.  
  5751. #ifdef KILLT
  5752. INTSIZE __far __aligned killt[0x4000];
  5753. #endif
  5754. const INTSIZE __aligned value[7] =
  5755. {0, valueP, valueN, valueB, valueR, valueQ, valueK};
  5756. const INTSIZE __aligned control[7] =
  5757. {0, ctlP, ctlN, ctlB, ctlR, ctlQ, ctlK};
  5758. INTSIZE __aligned stage, stage2, Developed[2];
  5759. FILE __aligned *hashfile;
  5760. unsigned int __aligned starttime;
  5761. INTSIZE int __aligned ahead = true, hash = true;
  5762.  
  5763. #if defined CHESSTOOL || defined XBOARD
  5764. void
  5765. TerminateChess (int sig)
  5766. {
  5767.   ExitChess();
  5768. }
  5769. #endif
  5770.  
  5771. int __aligned timeopp[MINGAMEIN], timecomp[MINGAMEIN];
  5772. int __aligned compptr, oppptr;
  5773.  
  5774. inline void
  5775. TimeCalc ()
  5776. {
  5777. /* adjust number of moves remaining in gamein games */
  5778.   int increment = 0;
  5779.   int topsum = 0;
  5780.   int tcompsum = 0;
  5781.   int me,him;
  5782.   int i;
  5783. /* dont do anything til you have enough numbers */
  5784.   if (GameCnt < (MINGAMEIN * 2)) return;
  5785. /* calculate average time in sec for last MINGAMEIN moves */
  5786.   for (i = 0; i < MINGAMEIN; i++)
  5787.     {
  5788.       tcompsum += timecomp[i];
  5789.       topsum += timeopp[i];
  5790.     }
  5791.   topsum /= (100 * MINGAMEIN);
  5792.   tcompsum /= (100 * MINGAMEIN);
  5793. /* if I have less time than opponent add another move */
  5794.     me = TimeControl.clock[computer]/100; 
  5795.     him = TimeControl.clock[opponent]/100;
  5796.     if(me < him) increment += 2;
  5797. /* if I am losing more time with each move add another */
  5798.   /*if ( !((me - him) > 60) && tcompsum > topsum) increment++;*/
  5799.   if ( tcompsum > topsum) increment +=2;
  5800. /* but dont let moves go below MINMOVES */
  5801.   else if (TimeControl.moves[computer] < MINMOVES && !increment) increment++;
  5802. /* if I am doing really well use more time per move */
  5803.   else if (me > him && tcompsum < topsum) increment = -1;
  5804.   TimeControl.moves[computer] += increment;
  5805. }
  5806.  
  5807.  
  5808. /* hmm.... shouldn`t main be moved to the interface routines */
  5809. int
  5810. main (int aargc, char **aargv)
  5811. {
  5812.   char cstring[40];
  5813.   char *xwin = 0;
  5814.   char *Lang = NULL;
  5815.  
  5816. #ifdef AMIGA
  5817.  int tmpargcnt;
  5818.  struct WBStartup *startmsg;
  5819.  struct ExecBase **execbaseptr=(struct ExecBase **)4L;
  5820.  UWORD cpuid;
  5821.  struct ExecBase *execbase;
  5822.  BPTR fp;
  5823.  APTR tempxx;
  5824.  struct WBArg *mywbptr;
  5825.  struct DiskObject *dob;
  5826.  
  5827.  execbase = *execbaseptr;
  5828.  cpuid = execbase->AttnFlags;
  5829.  
  5830.  if (!(cpuid & AFF_68020))
  5831.   {
  5832.    exit(0);
  5833.   }
  5834.  gfxversion = GfxBase->LibNode.lib_Version;
  5835.  if (gfxversion < 37)
  5836.   exit(-1);
  5837.  if (!aargc)
  5838.   {
  5839.    startmsg = (struct WBStartup *)aargv;
  5840.    mywbptr = startmsg->sm_ArgList; 
  5841.    if (dob = GetDiskObject (mywbptr->wa_Name))
  5842.     {
  5843.      xwin = FindToolType(dob->do_ToolTypes,"PRI");
  5844.      if (xwin)
  5845.       {
  5846.        procpri = xwin[0] - '0';
  5847.        if (procpri < 0)
  5848.         procpri = 0;
  5849.        if (procpri > 4)
  5850.         procpri = 4;
  5851.       }
  5852.      xwin = FindToolType(dob->do_ToolTypes,"COLORS");
  5853.      if (xwin)
  5854.       {
  5855.        if ((xwin[0] == '1')&&(xwin[1] == '6'))
  5856.         gfxversion = 37;
  5857.        else if ((xwin[0] == '6')&&(xwin[1] == '4'))
  5858.         FasterDisplay = 1;
  5859.       }
  5860.      xwin = FindToolType(dob->do_ToolTypes,"MONITOR");
  5861.      if (xwin)
  5862.       {
  5863.        if ((xwin[0] == '1')&&(xwin[1] == '5'))
  5864.         v15Khz = 1;
  5865.       }
  5866.      xwin = FindToolType(dob->do_ToolTypes,"FASTAGA");
  5867.      if (xwin)
  5868.       {
  5869.        if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  5870.         FasterDisplay = 1;
  5871.       }
  5872.      xwin = FindToolType(dob->do_ToolTypes,"SUPER72");
  5873.      if (xwin)
  5874.       {
  5875.        if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  5876.         Super72 = 1;
  5877.       }
  5878.      xwin = FindToolType(dob->do_ToolTypes,"RTG");
  5879.      if (xwin)
  5880.       {
  5881.        if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  5882.         RTG = 1;
  5883.       }
  5884. //     xwin = FindToolType(dob->do_ToolTypes,"PICASSO");
  5885. //     if (xwin)
  5886. //      {
  5887. //       if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  5888. //        Picasso = 1;
  5889. //      }
  5890.      xwin = FindToolType(dob->do_ToolTypes,"NO_BOBS");
  5891.      if (xwin)
  5892.       {
  5893.        if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  5894.         SYSTEM_BOBS = 0;
  5895.       }
  5896.      FreeDiskObject (dob);
  5897.     }
  5898.    xwin = 0L;
  5899.   }
  5900.  else if (aargc > 1)
  5901.   {
  5902.    for(tmpargcnt=1;tmpargcnt<aargc;tmpargcnt++)
  5903.     {
  5904.      if (!(strcmp(aargv[tmpargcnt],"16")))
  5905.       {
  5906.        gfxversion = 37;
  5907.       }
  5908.      else if (!(stricmp(aargv[tmpargcnt],"Super72")))
  5909.       {
  5910.        Super72 = 1;
  5911.       }
  5912.      else if (!(stricmp(aargv[tmpargcnt],"RTG")))
  5913.       {
  5914.        RTG = 1;
  5915.       }
  5916.      else if (!(stricmp(aargv[tmpargcnt],"NOBOBS")))
  5917.       {
  5918.        SYSTEM_BOBS = 0;
  5919.       }
  5920.      else if (!(stricmp(aargv[tmpargcnt],"15KHZ")))
  5921.       {
  5922.        v15Khz = 1;
  5923.       }
  5924. //     else if (!(stricmp(aargv[tmpargcnt],"PICASSO")))
  5925. //      {
  5926. //       Picasso = 1;
  5927. //      }
  5928.      else if ((!(stricmp(aargv[tmpargcnt],"FASTAGA")))||((!(strcmp(aargv[tmpargcnt],"64")))))
  5929.       {
  5930.        FasterDisplay = 1;
  5931.       }
  5932.      else if (strcmp(aargv[tmpargcnt],"256"))
  5933.       {
  5934.        procpri=atoi(aargv[tmpargcnt]);
  5935.        if (procpri < 0)
  5936.          procpri = 0;
  5937.        if (procpri > 4)
  5938.         procpri = 4;
  5939.       }
  5940.     }
  5941.   }
  5942.  if (gfxversion < 39)
  5943.   RTG = Super72 = 0;
  5944.  if (RTG)
  5945.   {
  5946.    FasterDisplay = 0;
  5947.    v15Khz = 0;
  5948.   }
  5949. // if (!RTG)
  5950. //  Picasso = 0;
  5951.  Delay(3L);
  5952.  myproc = (struct Process *)FindTask(0L);
  5953.  tempxx = myproc->pr_WindowPtr;
  5954.  Delay(3L);
  5955.  myproc->pr_WindowPtr = (APTR)-1L;
  5956.  if (!(fp = Open("uchess:uchess.lang",MODE_OLDFILE)))
  5957.   {
  5958.    system("Assign >nil: uchess: \"\"");
  5959.   }
  5960.  else
  5961.   Close(fp);
  5962.  myproc->pr_WindowPtr = tempxx;
  5963. #endif
  5964.  
  5965.   
  5966.   gsrand (starttime = ((unsigned int) time ((long *) 0)));    /* init urand */
  5967. #ifdef ttblsz
  5968.   ttblsize = ttblsz;
  5969.   rehash = -1;
  5970. #endif /* ttblsz */
  5971.   flag.easy = 0;
  5972. #ifndef AMIGA
  5973.   if (argc > 2)
  5974.     {
  5975.       if (argv[1][0] == '-' && argv[1][1] == 'L')
  5976.     {
  5977.       Lang = argv[2];
  5978.       argv += 2;
  5979.       argc -= 2;
  5980.     }
  5981.     }
  5982. #endif
  5983.   InitConst (Lang);
  5984.   ColorStr[0] = CP[118];
  5985.   ColorStr[1] = CP[119];
  5986.  
  5987. #ifndef AMIGA
  5988.   while (argc > 1 && ((argv[1][0] == '-') || (argv[1][0] == '+')))
  5989.     {
  5990.       switch (argv[1][1])
  5991.     {
  5992.     case 'a':
  5993.       ahead = ((argv[1][0] == '-') ? false : true);
  5994.       break;
  5995.     case 'h':
  5996.       hash = ((argv[1][0] == '-') ? false : true);
  5997.       break;
  5998.     case 's':
  5999.       argc--;
  6000.       argv++;
  6001.       if (argc > 1)
  6002.         strcpy (savefile, argv[1]);
  6003.       break;
  6004.     case 'l':
  6005.       argc--;
  6006.       argv++;
  6007.       if (argc > 1)
  6008.         strcpy (listfile, argv[1]);
  6009.       break;
  6010.  
  6011. #if ttblsz
  6012.     case 'r':
  6013.       if (argc > 2)
  6014.         rehash = atoi (argv[2]);
  6015.       argc--;
  6016.       argv++;
  6017.       if (rehash > MAXrehash)
  6018.         rehash = MAXrehash;
  6019.       break;
  6020.     case 'T':
  6021.       if (argc > 2)
  6022.         ttblsize = atoi (argv[2]);
  6023.       argc--;
  6024.       argv++;
  6025.       if (ttblsize > 0 && ttblsize < 24)
  6026.         ttblsize = (1 << ttblsize);
  6027.       else
  6028.         ttblsize = ttblsz;
  6029.       break;
  6030. #ifdef HASHFILE
  6031.     case 't':        /* create or test persistent transposition
  6032.                  * table */
  6033.       hashfile = fopen (HASHFILE, RWA_ACC);
  6034.       if (hashfile)
  6035.         {
  6036.           fseek (hashfile, 0L, SEEK_END);
  6037.           filesz = (ftell (hashfile) / sizeof (struct fileentry)) - 1;
  6038.         }
  6039.       if (hashfile != NULL)
  6040.         {
  6041.           long i, j;
  6042.           int nr[MAXDEPTH];
  6043.           struct fileentry n;
  6044.  
  6045.           /*ShowMessage (CP[49]);*/
  6046.           for (i = 0; i < MAXDEPTH; i++)
  6047.         nr[i] = 0;
  6048.           fseek (hashfile, 0L, SEEK_END);
  6049.           i = ftell (hashfile) / sizeof (struct fileentry);
  6050.           fseek (hashfile, 0L, SEEK_SET);
  6051.           for (j = 0; j < i + 1; j++)
  6052.         {
  6053.           fread (&n, sizeof (struct fileentry), 1, hashfile);
  6054.           if (n.depth)
  6055.             {
  6056.               nr[n.depth]++;
  6057.               nr[0]++;
  6058.             }
  6059.         }
  6060.           sprintf (astr,CP[109],
  6061.               nr[0], i);
  6062.               /*ShowMessage(astr);*/
  6063.           for (j = 1; j < MAXDEPTH; j++)
  6064.                /*
  6065.         printf ("%d ", nr[j]);
  6066.           printf ("\n")*/;
  6067.         }
  6068.       return 0;
  6069.     case 'c':        /* create or test persistent transposition
  6070.                  * table */
  6071.       if (argc > 2)
  6072.         filesz = atoi (argv[2]);
  6073.       if (filesz > 0 && filesz < 24)
  6074.         filesz = (1 << filesz) - 1 + MAXrehash;
  6075.       else
  6076.         filesz = Deffilesz + MAXrehash;
  6077.       if ((hashfile = fopen (HASHFILE, RWA_ACC)) == NULL)
  6078.         hashfile = fopen (HASHFILE, WA_ACC);
  6079.       if (hashfile != NULL)
  6080.         {
  6081.           long j;
  6082.           struct fileentry n;
  6083.  
  6084.           /*printf (CP[66]);*/
  6085.           for (j = 0; j < 32; j++)
  6086.         n.bd[j] = 0;
  6087.           n.f = n.t = 0;
  6088.           n.flags = 0;
  6089.           n.depth = 0;
  6090.           n.sh = n.sl = 0;
  6091.           for (j = 0; j < filesz + 1; j++)
  6092.         fwrite (&n, sizeof (struct fileentry), 1, hashfile);
  6093.           fclose (hashfile);
  6094.         }
  6095.      /* else
  6096.         printf (CP[50], HASHFILE);*/
  6097.       return (0);
  6098. #endif /* HASHFILE */
  6099. #endif /* ttblsz */
  6100.     case 'x':
  6101.       xwin = &argv[1][2];
  6102.       break;
  6103.     case 'v':
  6104. /*      fprintf (stderr, CP[102], version, patchlevel);*/
  6105.       exit (1);
  6106.     default:
  6107.       /*fprintf (stderr, CP[113]);*/
  6108.       exit (1);
  6109.     }
  6110.       argv++;
  6111.       argc--;
  6112.     }
  6113. #endif
  6114.   XC = 0;
  6115.   MaxResponseTime = 0;
  6116. #if defined CHESSTOOL || defined XBOARD
  6117.   signal (SIGTERM, TerminateChess);
  6118.   TCflag = true;
  6119.   TCmoves = 40;
  6120.   TCminutes = 120;
  6121.   TCseconds = 0;
  6122.   TCadd = 0;
  6123.   OperatorTime = 0;
  6124. #else
  6125. /*  TCflag = false;*/
  6126. /*  OperatorTime = 0;*/
  6127.   TCflag = true;
  6128.   TCmoves = 60;
  6129.   TCminutes = 10;
  6130.   TCseconds = 0;
  6131.   OperatorTime = 0;
  6132. #endif
  6133. #ifndef AMIGA
  6134.   if (argc == 2)
  6135.     {
  6136.       char *p;
  6137.  
  6138.       MaxResponseTime = 100L*strtol(argv[1], &p, 10);
  6139.       if (*p == ':')
  6140.     MaxResponseTime = 60L*MaxResponseTime + 
  6141.         100L*strtol(++p, (char **) NULL, 10);
  6142.       TCflag = false;
  6143.       TCmoves = 0;
  6144.       TCminutes = 0;
  6145.       TCseconds = 0;
  6146.     }
  6147.   if (argc >= 3)
  6148.     {
  6149.       char *p;
  6150.       if (argc > 9)
  6151.     {
  6152.      /* printf ("%s\n", CP[220]);*/
  6153.       exit (1);
  6154.     }
  6155.       TCmoves = atoi (argv[1]);
  6156.       TCminutes = strtol (argv[2], &p, 10);
  6157.       if (*p == ':')
  6158.     TCseconds = strtol (p + 1, (char **) NULL, 10);
  6159.       else
  6160.     TCseconds = 0;
  6161.       TCflag = true;
  6162.       argc -= 3;
  6163.       argv += 3;
  6164.       while (argc > 1)
  6165.     {
  6166.       XCmoves[XC] = atoi (argv[0]);
  6167.       XCminutes[XC] = strtol (argv[1], &p, 10);
  6168.       if (*p == ':')
  6169.         XCseconds[XC] = strtol (p + 1, (char **) NULL, 10);
  6170.       else
  6171.         XCseconds[XC] = 0;
  6172.       if (XCmoves[XC] && (XCminutes[XC] || XCseconds[XC]))
  6173.         XC++;
  6174.       else
  6175.         {
  6176.           /*printf (CP[220]);*/
  6177.           exit (1);
  6178.         }
  6179.       argc -= 2;
  6180.       argv += 2;
  6181.     }
  6182.       if (argc)
  6183.     {
  6184.       /*printf ("%s\n", CP[220]);*/
  6185.       exit (1);
  6186.     }
  6187.     }
  6188. #endif /* AMIGA */
  6189. #ifdef AMIGA
  6190.  (void)SetTaskPri((struct Task *)myproc,procpri);
  6191.  Delay(3L);
  6192.  if (!AmigaStartup())
  6193.   {
  6194.    exit(2);
  6195.   }
  6196. #endif
  6197.   Initialize ();
  6198. #ifndef CACHE
  6199. #ifdef ttblsz
  6200.   Initialize_ttable ();
  6201. #endif /* ttblsz */
  6202. #endif
  6203.   Initialize_dist ();
  6204.   Initialize_moves ();
  6205.   FirstTime = 1;
  6206.   NewGame ();
  6207.   flag.easy = ahead;
  6208.   flag.hash = hash;
  6209.   if (xwin)
  6210.     xwndw = atoi (xwin);
  6211.  
  6212.   hashfile = NULL;
  6213. #if ttblsz
  6214. #ifdef HASHFILE
  6215.   hashfile = fopen (HASHFILE, RWA_ACC);
  6216.   if (hashfile)
  6217.     {
  6218.       fseek (hashfile, 0L, SEEK_END);
  6219.       filesz = ftell (hashfile) / sizeof (struct fileentry) - 1;
  6220.     }
  6221. #if !defined CHESSTOOL && !defined XBOARD
  6222.   else
  6223.     ShowMessage (CP[98]);
  6224. #endif
  6225. #endif /* HASHFILE */
  6226. #endif /* ttblsz */
  6227. #ifdef AMIGA
  6228.  SetMenuStrip(wG,&MenuList1);    /* attach any Menu */
  6229.  MenuStripSet = 1;
  6230.  EnableMoveNow();
  6231. #endif
  6232.   while (!(flag.quit))
  6233.     {
  6234.       oppptr = (oppptr + 1) % MINGAMEIN;
  6235.       if (flag.bothsides && !flag.mate)
  6236.        {
  6237.         SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  6238.     SelectMove (opponent, 1);
  6239.        }
  6240.       else
  6241.         {
  6242.       InputCommand (cstring);
  6243.         }
  6244.  
  6245.       if (opponent == black)
  6246.     if (flag.gamein || TCadd)
  6247.       {
  6248.         TimeCalc ();
  6249.       }
  6250.     else if (TimeControl.moves[opponent] == 0)
  6251.       {
  6252.         if (XC)
  6253.           if (XCmore < XC)
  6254.         {
  6255.           TCmoves = XCmoves[XCmore];
  6256.           TCminutes = XCminutes[XCmore];
  6257.           TCseconds = XCseconds[XCmore];
  6258.           XCmore++;
  6259.         }
  6260.         SetTimeControl2 (opponent);
  6261.       }
  6262.  
  6263.       compptr = (compptr + 1) % MINGAMEIN;
  6264.  
  6265.  
  6266.       if (SupervisorMode)
  6267.        {
  6268.       computer = computer ^ 1;
  6269.       opponent = opponent ^ 1;
  6270.       xwndw = (computer == white) ? WXWNDW : BXWNDW;
  6271.       flag.force = false;
  6272.       Sdepth = 0;
  6273.        }
  6274.       else if (!(flag.quit || flag.mate || flag.force))
  6275.     {
  6276.           SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  6277.       SelectMove (computer, 1);
  6278.       if (computer == black)
  6279.         if (flag.gamein)
  6280.           {
  6281.         TimeCalc ();
  6282.           }
  6283.         else if (TimeControl.moves[computer] == 0)
  6284.           {
  6285.         if (XC)
  6286.           if (XCmore < XC)
  6287.             {
  6288.               TCmoves = XCmoves[XCmore];
  6289.               TCminutes = XCminutes[XCmore];
  6290.               TCseconds = XCseconds[XCmore];
  6291.               XCmore++;
  6292.             }
  6293.         SetTimeControl2 (computer);
  6294.           }
  6295.     }
  6296.       if ((flag.mate)&&(!Mate)&&(!DrawnGame))
  6297.        ShowMessage("CheckMate");
  6298.       if (Mate)
  6299.        {
  6300.         ShowMessage(MateString);
  6301.        }
  6302.       else if (DrawnGame)
  6303.        {
  6304.         ShowMessage("Draw..");
  6305.        }
  6306.       else if ((!flag.mate)&&(PlayMode == 2)&&(!ResignOffered)&&(!flag.quit))
  6307.        {
  6308.         if (global_tmp_score < -950)
  6309.          {
  6310.           if (DoResign())
  6311.            {
  6312.             ClearPointer(wG);
  6313.             flag.mate = true;
  6314.             flag.back = true;
  6315.             Mate = 1;
  6316.             ShowMessage("You Win!");
  6317.             ShowMessage("UChess Resigns");
  6318.            }
  6319.          }
  6320.        }
  6321.     }
  6322. #if ttblsz
  6323. #ifdef HASHFILE
  6324.   if (hashfile)
  6325.     fclose (hashfile);
  6326. #endif /* HASHFILE */
  6327. #endif /* ttblsz */
  6328.  
  6329.   ExitChess ();
  6330. }
  6331.